I have a question that I haven’t been able to solve for days.
I am making an application in React Natice and I wanted to install a Google ad in this application. I used the react-native-google-mobile-ads package for this. However, every time I run the project, I get the Execution failed for task ‘:react-native-google-mobile-ads:compileDebugKotlin’ error. However, when I install this package in an empty project, it works without any problems. Why does this problem occur?
package.json
"@react-native-async-storage/async-storage": "^1.19.3",
"@react-native-picker/picker": "^2.5.1",
"@react-navigation/bottom-tabs": "^6.5.8",
"@react-navigation/drawer": "^6.6.3",
"@react-navigation/material-bottom-tabs": "^6.2.17",
"@react-navigation/native": "^6.1.7",
"@react-navigation/native-stack": "^6.9.13",
"@react-navigation/stack": "^6.3.17s",
"axios": "^1.5.1",
"cheerio": "^1.0.0-rc.12",
"lottie-react-native": "^6.3.1",
"metro-config": "^0.77.0",
"react": "18.2.0",
"react-native": "0.72.5",
"react-native-dropdown-picker": "^5.4.6",
"react-native-gesture-handler": "^2.12.0",
"react-native-google-mobile-ads": "^12.3.0",
"react-native-paper": "^5.10.6",
"react-native-picker-select": "^8.1.0",
"react-native-reanimated": "^3.3.0",
"react-native-safe-area-context": "^4.7.0",
"react-native-screens": "^3.22.1",
"react-native-vector-icons": "^10.0.0"
build.gradle
buildscript {
ext {
buildToolsVersion = "33.0.0"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
kotlinVersion = "1.9.0"
ndkVersion = "23.1.7779620"
}
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0"
}
}
2
Answers
For react-native-gesture-handler, I had to use the kotlin version in build.gradle. That's why I used version 1.9, but react-native-google-mobile-ads was using 1.8, so I downgraded the version and it worked.
kotlinVersion = "1.9.0" is not working. 1.8.x is working