React-native Awesome project not building android project - react-native

I am trying to learn react-native but am not able to build the demo AwesomeProject. I have set the $ANDROID_HOME variable in ~/.bash_profilefile. But every time I build it I get following error.
What went wrong:
A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugCompile'.
Could not find com.android.support:appcompat-v7:23.0.1.
Searched in the following locations:
file:/Users/<username>/.m2/repository/com/android/support/appcompat-v7/23.0.1/appcompat-v7-23.0.1.pom
file:/Users/<username>/.m2/repository/com/android/support/appcompat-v7/23.0.1/appcompat-v7-23.0.1.jar
https://jcenter.bintray.com/com/android/support/appcompat-v7/23.0.1/appcompat-v7-23.0.1.pom
https://jcenter.bintray.com/com/android/support/appcompat-v7/23.0.1/appcompat-v7-23.0.1.jar
Required by:
AwesomeProject:app:unspecified
Could not find com.android.support:appcompat-v7:23.0.1.
Searched in the following locations:
file:/Users/<username>/.m2/repository/com/android/support/appcompat-v7/23.0.1/appcompat-v7-23.0.1.pom
file:/Users/<username>/.m2/repository/com/android/support/appcompat-v7/23.0.1/appcompat-v7-23.0.1.jar
https link Required by:
AwesomeProject:app:unspecified > com.facebook.react:react-native:0.11.0
Could not find com.android.support:support-v4:21.0.3.
Searched in the following locations:
file:/Users/<username>/.m2/repository/com/android/support/support-v4/21.0.3/support-v4-21.0.3.pom
file:/Users/<username>/.m2/repository/com/android/support/support-v4/21.0.3/support-v4-21.0.3.jar
https link
Required by:
AwesomeProject:app:unspecified > com.facebook.react:react-native:0.11.0 > com.facebook.fresco:fresco:0.6.1 > com.facebook.fresco:drawee:0.6.1
AwesomeProject:app:unspecified > com.facebook.react:react-native:0.11.0 > com.facebook.fresco:fresco:0.6.1 > com.facebook.fresco:imagepipeline:0.6.1
I don't know why it's looking in this folder file:
/Users/<username>/.m2/repository/com/android/support/appcompat-v7/23.0.1
Installed sdk version is 23.0.1 still I am getting this error.
I have a dotnet background trying to learn react-native.

Finally got it. You have to install Android Support Repository in Extras, in the Android SDK manager
Open the SDK, scroll down to the last part, open the extras, select android support repository, and click on "install packages" here is a screenshot

Related

Could not resolve all files for configuration ':react-native-android-location-enabler:classpath'

When trasfer project react-native project to Windows from Linux getting is error
A problem occurred configuring project ':react-native-android-location-enabler'.
> Could not resolve all files for configuration ':react-native-android-location-enabler:classpath'.
> Could not download builder-3.4.2.jar (com.android.tools.build:builder:3.4.2)
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/3.4.2/builder-3.4.2.jar'.
> Tag mismatch!
What is the best way to transfer react-native project OS from other OS

React native link fails with no package found

I'm not sure what exactly is happening but I am unable to run react-native link without errors occuring
CLI Output:
react-native link --verbose
debug Available platforms: iOS, Android
debug Targeted platforms: iOS, Android
debug Getting project config for iOS...
debug Getting project config for Android...
error No package found. Are you sure this is a React Native project?
error Unexpected close tag
Line: 22
Column: 24
Char: >
debug Error: Unexpected close tag
Line: 22
Column: 24
Char: >
at error (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/xmldoc/node_modules/sax/lib/sax.js:666:10)
at strictFail (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/xmldoc/node_modules/sax/lib/sax.js:692:7)
at closeTag (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/xmldoc/node_modules/sax/lib/sax.js:885:9)
at SAXParser.write (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/xmldoc/node_modules/sax/lib/sax.js:1447:13)
at new XmlDocument (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/xmldoc/lib/xmldoc.js:199:15)
at readManifest (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/#react-native-community/cli/build/tools/android/readManifest.js:44:10)
at Object.projectConfig (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/#react-native-community/cli/build/tools/android/index.js:66:46)
at Object.keys.forEach.platform (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/#react-native-community/cli/build/commands/link/getProjectConfig.js:25:62)
at Array.forEach (<anonymous>)
at getProjectConfig (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/#react-native-community/cli/build/commands/link/getProjectConfig.js:22:35)
This randomly started happening after attempting to npm install react-native-firebase.
What I've tried
clear-caches
remove node_modules and npm install
Checking out my code back to a previous commit
Adding my package name to the manifest locaed in /android/app/src/debug/AndroidManifest.xml
Removing the app from my computer and cloning it from github
Running react-native link on another project, which works, but i just can't run react-native link on this specific project.
So the answer to my question was that in my android manifest xml file, there was an incorrect closing brace for one of my intent filters.
So for anyone that this happens to ensure that all of your Android files have correct syntax.
I fixed this problem by closing some unclosed tag in android/app/src/main/androidManifest.xml. Try checking the file line by line.

React Native Android fails: error 3

Hope you could help me here:
I'm currently building an app which I created through CRNA and then ejected. I get the ios version right on but I'm currently struggling a lot with the android version.
When running react-native run-android all I can get is the following error:
Error type 3
Error: Activity class {com.myapp/com.myapp.MainActivity} does not exist.
I've checked app/build.gradle, app/src/main/AndroidManifest.xml, app/src/main/java/com/myapp/MainActivity.java and app/src/main/java/com/myapp/MainActivity.java for name errors on package. I've tried moving from com.myapp to com.mebius.myapp and com aswell.
Seems this comes from the only plugin I'm using. I'm keeping on the investigation
Any hints?
There are 3 possible reasons for the android app build fails to make
1. You need to define sdk path in android/local.properties
if local.properties doesn't place then make a file names with that
add
sdk.dir = home/user/AndroidApp/local/Sdk
You can match with their system path..
2. Your genymotion or avd must enable with the android studio
3. You must have to go with the following command
npm start
in new terminal .
Please go through with it.
Thanks
Actually I had a problem with my gradle config which look like:
include ':react-native-sensors'
project(':react-native-sensors').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sensors/android')
rootProject.name = 'accelapp'
I needed to add: include ':app'
I don't know if it's due to the process of ejecting from CRNA or if it's due to react-native link react-native-sensors though.
EDIT After some investigation, I couldn't reproduce this issue. This leads me to say it was a faulty copy/paste...

Could not find com.android.support:support-v4:23.2.1

When using react-native 0.28 and above (0.29, 0.30-rc), I get the following error when executing react-native run-android in a fresh react-native init app project.
Could not find com.android.support:support-v4:23.2.1.
I installed the newest android studio and even installed the obsolete library manually.
What am I doing wrong?
Thanks!
To complete Tonithy's answer - the .jar may not be enough, you need to copy two whole directories, otherwise gradle will complain for the missing .aar. In this case, I think that those were installed by Android Studio:
{USER}/Library/Android/sdk/extras/android/m2repository/com/android/support/support-v4/23.2.1/
And don't forget the dependency:
{USER}/Library/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/23.2.1/
I had exactly the same problem while upgrading to react-native 0.30, that solved the issue.
Google seems to have stopped including a version of each support library without sources/javadoc/etc and React is looking for this specific file. Assuming you manually installed the obsolete version, it will be in {YOUR_ANDROID_LOCATION}/extras/android/support/v4/android-support-v4.jar Your best bet is to manually copy it in:
cp {YOUR_ANDROID_LOCATION}/extras/android/support/v4/android-support-v4.jar {YOUR_ANDROID_LOCATION}/extras/android/m2repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
This a React Native (version and probably OSX specific bug), it will probably be fixed soon. For posterity, your full error was something like this, looking for support in all the wrong places:
OsagieTheGreat-MBA:somereactapp osagiethegreat$ react-native run-android
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not find com.android.support:support-v4:23.2.1.
Searched in the following locations:
file:/Users/osagiethegreat/.m2/repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
file:/Users/osagiethegreat/.m2/repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
https://jcenter.bintray.com/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
https://jcenter.bintray.com/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
file:/Users/osagiethegreat/Documents/somereactapp/node_modules/react-native/android/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
file:/Users/osagiethegreat/Documents/somereactapp/node_modules/react-native/android/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
file:/Applications/Android Dev/sdk/extras/android/m2repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
file:/Applications/Android Dev/sdk/extras/android/m2repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
file:/Applications/Android Dev/sdk/extras/google/m2repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
file:/Applications/Android Dev/sdk/extras/google/m2repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
Required by:
SomeReactApp:app:unspecified > com.android.support:appcompat-v7:23.0.1
SomeReactApp:app:unspecified > com.facebook.react:react-native:0.29.0 > com.android.support:recyclerview-v7:23.0.1
> Could not find com.android.support:support-v4:23.2.1.
Searched in the following locations:
file:/Users/osagiethegreat/.m2/repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
file:/Users/osagiethegreat/.m2/repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
https://jcenter.bintray.com/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
https://jcenter.bintray.com/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
file:/Users/osagiethegreat/Documents/somereactapp/node_modules/react-native/android/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
file:/Users/osagiethegreat/Documents/somereactapp/node_modules/react-native/android/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
file:/Applications/Android Dev/sdk/extras/android/m2repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
file:/Applications/Android Dev/sdk/extras/android/m2repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
file:/Applications/Android Dev/sdk/extras/google/m2repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
file:/Applications/Android Dev/sdk/extras/google/m2repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
Required by:
SomeReactApp:app:unspecified > com.facebook.react:react-native:0.29.0 > com.facebook.fresco:imagepipeline-okhttp3:0.11.0 > com.facebook.fresco:imagepipeline:0.11.0
SomeReactApp:app:unspecified > com.facebook.react:react-native:0.29.0 > com.facebook.fresco:fresco:0.11.0 > com.facebook.fresco:drawee:0.11.0
SomeReactApp:app:unspecified > com.facebook.react:react-native:0.29.0 > com.facebook.fresco:imagepipeline-okhttp3:0.11.0 > com.facebook.fresco:imagepipeline:0.11.0 > com.facebook.fresco:imagepipeline-base:0.11.0
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 10.838 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
I also got this error, after installing Android Support Library the error has gone.
Install Android Support Library from Extras
First solution could be adding this
compile 'com.android.tools:sdklib:23.2.1'
to the next file
android/app/build.gradle
Second solution is installing Android Support Repository
To Complete Tonithy's and Simon's answer, yes the jar itself was not enough, all the files of two directories -
extras/android/m2repository/com/android/support/support-v4/23.2.1/ and
extras/android/m2repository/com/android/support/support-annotations/23.2.1/ are needed. On my Windows PC, I couldn't find files of these directories anywhere.
So what I did was, I downloaded these folders from googlesource
1. support/support-annotations/23.2.1
Download tgz of above folder and extract the files into {YOUR_ANDROID_LOCATION}/extras/android/m2repository/com/android/support/support-annotations/23.2.1/
2. support/support-v4/23.2.1
Download tgz of above folder and extract the files into {YOUR_ANDROID_LOCATION}/extras/android/m2repository/com/android/support/support-v4/23.2.1/
Now go to your command propmt or terminal and run react-native run-android
Hope it save someone few hours!!

Could not find com.google.gms:google-services:9.0,0

The Sync failed when tried to add the dependency for google play service. The problem seem to its looking for the jar in C:/Program/Files/Android/Android Studio however my SDK is placed in C:\Android\sdk. However I also have Android Studio in Program Files where there are no jar for Google play services.
Information:Gradle tasks [clean, :app:generateDebugSources, :app:compileDebugSources]
Error:A problem occurred configuring root project 'XXXXXX'.
Could not resolve all dependencies for configuration ':classpath'.
Could not find com.google.gms:google-services:9.0.0.
Searched in the following locations:
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/google-services/9.0.0/google-services-9.0.0.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/google-services/9.0.0/google-services-9.0.0.jar
https://jcenter.bintray.com/com/google/gms/google-services/9.0.0/google-services-9.0.0.pom
https://jcenter.bintray.com/com/google/gms/google-services/9.0.0/google-services-9.0.0.jar
Required by:
:XXXXX:unspecified
Information:BUILD FAILED
Information:Total time: 6.148 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
Also my ANDROID_HOME is set to C:\Android\sdk.
Please advise.
By checking other SO question. You can find that Google Play Service updating to version 9.0.0 has a bug issue.
Some solution is by checking if you have enabled offline work for gradle, deselect Offline Work if it's checked. Then, confirm if you have latest version of Google services mentioned as dependencies in project level build.gradle: classpath 'com.google.gms:google-services:3.0.0'. Clean and build the project after the gradle sync completes.
Also, some people fixed it by just deleting the debug.keystore file found in the android folder.
Check this SO question for more information.