I get this error on running ./gradlew assembleRelease
Error:
FAILURE: Build failed with an exception.
package.json
"react": "16.5.0",
"react-native": "0.57.0",
"react-native-admob": "^2.0.0-beta.5",
I'm also getting the same error. I have the same version for react, react-native and admob.
I would like to add that my build.gradle configuration is:
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
Check this out https://github.com/facebook/react-native/issues/19239
go to node_module/react-native-admob/android
open build.gradle
compileSdkVersion 27
buildToolsVersion "27.0.3"
This pull request solved that issue for me: https://github.com/sbugert/react-native-admob/pull/354. It's exactly what @andylah wrote.
@andylah solution did it for me. Thank you!
@andylah Your solution work. but i wondering what about "targetSdkVersion 22"
Do i need to change to 26 also?
@gongsunzan @celest67 Can you please upvote and approve #354 if it works for you too?
i tried the solution from @andylah but than another problem is happening.
../node_modules/react-native-admob/android/build.gradle: Error: All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 26.1.0. Examples include com.android.support:animated-vector-drawable:27.1.1 and com.android.support:customtabs:26.1.0 [GradleCompatible]
i extended the build.gradle by adding other dependencies.
dependencies {
compile 'com.facebook.react:react-native:+'
compile 'com.google.android.gms:play-services-ads:+'
implementation 'com.android.support:customtabs:27.1.1'
implementation 'com.android.support:animated-vector-drawable:27.1.1'
implementation 'com.android.support:support-media-compat:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
}
after this i can build the apk
@andylah Thank you. your solution is working.
Below solution doesn't need to change any node_modules. Might be helpful.
Add this code below project level build.gradle.
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
}
}
}
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.1"
}
}
}
}
Upgrading buildVersionTools to 28.0.3 solved my issue.
for me the following worked
compileSdkVersion 28
buildToolsVersion "28.0.3"
worked with me
subprojects {
project.configurations.all {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
}
}
}
}
}
go to node_module/react-native-admob/android
open build.gradle
compileSdkVersion 27
buildToolsVersion "27.0.3"
AOOOOWWW ILOVEDD!!!!!!!!
Like @andylah said, we have to update node_module/react-native-admob/android/build.gradle
but in my case I have to update it to
compileSdkVersion 28
buildToolsVersion "28.0.3"
This is the same value like my build.gradle project android
Most helpful comment
go to node_module/react-native-admob/android
open build.gradle
compileSdkVersion 27
buildToolsVersion "27.0.3"