I suddenly started getting this error when trying to build. This was all working a few weeks ago with no changes that I know of. The issue seems to be related to react
To solve this problem:
Open package.json and edit the react version to:
"react": "16.0.0-alpha.3",
"react-native": "0.43.1",
Delete node_modules directory
And re-install npm with the command npm install
In Addition: If you get a app:compileDebugJava
ERROR, run react-native upgrade
(Got the solution from this github page and it worked for me)
For this, try one of the following option:
1. Update your SDK manager
> Go to build menu > clean project
> then build project
or
2. Right click on project folder > open module setting
> libraries
> add com.android.support:appcompat-v7:25.3.1
> sync
the project
3. Click on file
menu > open project structure
> and file the libraries
This seems to be an issue with react-native itself. There is no official fix for this (yet), however some people have reported upgrading to have solved their problem. You can check more details here
Update 1:
Hi @roachman, this is the exact error I got which pointed me to search for above. There is another ticket logged #14225 for same(cannot post link for some reason). I was just able to resolve it by including exact version of react-native version in build.gradle dependencies line compile "com.facebook.react:react-native:0.xx.y"
instead of compile 'com.facebook.react:react-native:+'
You might want to try that for all projects that use that setting or a more elegant settings suggested in above in issue #14223 by user david50407
Update 2 This is officially fixed now have a look https://github.com/facebook/react-native/issues/14225#issuecomment-305073392 (had to remove earlier link for issue 14223 as I cannot post more than 2 links)
If you upgraded react-native-fbsdk from 0.5 to 0.6 versions and have this issue then open your android project (pathToYourApp/android
) in Android Studio and it automatically offers you to update dependencies. Now It should work fine!
Add google maven in project gradle (Project: build.gradle
),
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Remove existing gradle cache
with below command
rm -fr ~/.gradle/caches/
My case was that this is react-native-fbsdk
build.gradle (https://github.com/facebook/react-native-fbsdk/blob/master/android/build.gradle):
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.facebook.react:react-native:+' // support react-native-v0.22-rc+
compile('com.facebook.android:facebook-android-sdk:4.+')
}
I am using React Native 0.37, so this is the line that broke for me:
compile('com.facebook.android:facebook-android-sdk:4.+')
Had to change to this for compatibility:
compile('com.facebook.android:facebook-android-sdk:4.18.+')