Getting error while running `react-native run-android`
As some has mentioned, the problem is that the RN build automatically "upgraded" to androidx.core:core:1.7.0-alpha01, which depends on SDK version 30.
The Fix
The fix is simply to specify android core version via androidXCore in build.gradle
buildscript { ext { buildToolsVersion = "29.0.3" minSdkVersion = 23 compileSdkVersion = 29 targetSdkVersion = 29 ndkVersion = "20.1.5948944" kotlin_version = "1.5.0" androidXCore = "1.5.0" }
How I figured it out
Figuring this out was painful. I grepped for gradle files that would automatically upgrade packages like so
find . -name '*.gradle' -exec grep -H "\.+" {} \;
and found in node_modules/@react-native-community/netinfo/android/build.gradle
the following snippet
def androidXCore = getExtOrInitialValue('androidXCore', null) if (supportLibVersion && androidXVersion == null && androidXCore == null) { implementation "com.android.support:appcompat-v7:$supportLibVersion" } else { def defaultAndroidXVersion = "1.+" if (androidXCore == null) { androidXCore = androidXVersion == null ? defaultAndroidXVersion : androidXVersion } implementation "androidx.core:core:$androidXCore" }}
Apparently they just broke this today.
You can fix it by adding the following line to your app level build.gradle file (above the android { }
block as a sibling):
configurations.all { resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' }}
Finally, the Gradle build was successfully completed. Ref. https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html
I got same issue. Just today. When I try to run locally, I got the exact same error. To get it run again, I update the field compileSdkVersion
and targetSdkVersion
in file android > build.gradle from 29 to 30. Then, it can run again. If this answer fits with you, you can go with this way. But, personally, I'm lookin for solution without to change the value compileSdkVersion
and targetSdkVersion
Update: just change the compileSdkVersion