react-native: Execution failed for task ':react-native-gradle-plugin:compileKotlin'.
New Version
0.69.0
Old Version
0.64.2
Build Target(s)
13
Output of react-native info
(Use node --trace-warnings ... to show where the warning was created)
System:
OS: macOS 12.1
CPU: (16) x64 Intel® Core™ i9-9880H CPU @ 2.30GHz
Memory: 174.05 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
Yarn: 1.22.11 - /usr/local/bin/yarn
npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
Watchman: 2022.07.04.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK:
API Levels: 23, 25, 27, 28, 29, 30, 31
Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0, 33.0.0
System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 4.2 AI-202.7660.26.42.7322048
Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
Languages:
Java: 11.0.15 - /Library/Java/JavaVirtualMachines/jdk-11.0.15.jdk/Contents/Home/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.69.0 => 0.69.0
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found
Issue and Reproduction Steps
Task :react-native-gradle-plugin:compileKotlin FAILED e: /Users/wartan/Documents/internationthink/medic-react-native/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (28, 33): Unresolved reference: replaceFirstChar e: /Users/wartan/Documents/internationthink/medic-react-native/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (28, 52): Unresolved reference: it e: /Users/wartan/Documents/internationthink/medic-react-native/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (252, 16): Unresolved reference: lowercase e: /Users/wartan/Documents/internationthink/medic-react-native/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt: (13, 38): Unresolved reference: lowercase e: /Users/wartan/Documents/internationthink/medic-react-native/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt: (15, 57): Unresolved reference: lowercase e: /Users/wartan/Documents/internationthink/medic-react-native/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt: (18, 54): Unresolved reference: lowercase e: /Users/wartan/Documents/internationthink/medic-react-native/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt: (19, 52): Unresolved reference: lowercase e: /Users/wartan/Documents/internationthink/medic-react-native/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt: (191, 27): Type mismatch: inferred type is Unit but CharSequence was expected e: /Users/wartan/Documents/internationthink/medic-react-native/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt: (191, 44): Unresolved reference: replaceFirstChar e: /Users/wartan/Documents/internationthink/medic-react-native/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt: (191, 63): Unresolved reference: it
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ‘:react-native-gradle-plugin:compileKotlin’.
Compilation error. See log for more details
- 
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. 
- 
Get more help at https://help.gradle.org 
BUILD FAILED in 15s
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 24
- Comments: 55 (3 by maintainers)
Hey @tsaurav18 @EJ132 @mickeylam @soundaryamecse after version 0.68 RN introduce New Architecture and for that they have upgrade the Gradle version to 7+ and you must have to upgrade your gradle to 7+
so if you want to use the New Architecture then you must have to update the gradle for
0.69+: that you have to adddistributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zipinandroid/gradle/wrapper/gradle-wrapper.propertiesand in
android/build.gradleyou have to addfor more information you can follow the React Native Upgrade Helper
hope this will work for you.
Same Problem, waiting for resolve solution.
This might be an issue due to wrong version or absence of JDK (not JRE). Install JDK11 worked for me. Run: brew install java11
sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
java --version
Thanks !!
Try:
@cortinico I followed the official support and way to update version, installed react-native-gradle-plugin and build compilation stucked at it, here’s the log
There are many things related to this.
1 - Open Android Studio and download the latest SDKS -> https://reactnative.dev/docs/environment-setup 2 - In wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zipThis solved my problem ( Also downgrade some packages)
I changed gradle version and solved it. (*reference : https://bocoder.tistory.com/125)
//before distributionUrl=https://services.gradle.org/distributions/gradle-6.9-bin.zip
//after distributionUrl=https://services.gradle.org/distributions/gradle-7.5.1-all.zip
No one replied this issue react native support. facing the same issues
i don’t think my solution is work for you guys, but this is the solution for my case.
My case is I’m installing Minecraft game, and the installer automatically installs java 8.
So I just uninstall that java 8 and now the issue is fixed
Same issue here. In package.json I prefixed the version with
^, thenyarn installand it started working."react-native": "^0.68.2"Same issue here. Trying to upgrade react-native version from
0.63.4to0.69.4I solve this problem!!!
If you are using React Native 0.60 or above, you can use the latest version of react-native-gradle-plugin, which is 2.0.0 at the time of writing. You can update your dependencies block to include: groovy Copy code
dependencies { // … classpath(“com.facebook.react:react-native-gradle-plugin:2.0.0”) // … } If you are using an older version of React Native, you can check the compatibility table provided by the react-native-gradle-plugin repository to find the suitable version for your React Native version. Here is the link to the compatibility table: react-native-gradle-plugin Compatibility Table.
it worked for me, thanks
I had a similar problem and after installing https://www.npmjs.com/package/react-native-gradle-plugin this package everything worked fine, maybe would be helpful for somebody.
As it worked for me, in
<PROJECT>/android/gradle/gradle/wrapper/gradle-wrapper.propertiesi changed the linedistributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zipbydistributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip.in android/build.gradle:
in the end in android/app/src/main/AndroidManifest.xml:
added the package
completed, opened Android Studio and synchronized the gradle…
hope to help
In my case, I assured 3 things for it to work:
In
gradle/wrapper/gradle-wrapper.properties:distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zipI checked for the last updates of the SDK Platform and tools on Android Studio, in the section
Preferences > Appearance & Behavior > System Settings > Android SDKAnd finally I uninstalled and reinstalled completely my Java JRE and JDK. Then I installed the last version of Java for my system (1.8.0_381-b09) and the JDK 11, recommended by React Native. After both procedures I restarted my computer, and after the last restart, I set my JAVA_HOME env variable to the place where JDK folder was placed.
Hope it helps.
P.D.: I am running react-native 0.71.8, and its worth to mention that my
android/build.gradlefile looks like this because of my implementation of VisionCamera to work:Thank you, guys!
My problem
_[Task :react-native-gradle-plugin:compileKotlin FAILED, 'compileJava' task (current target is 1.8) and 'compileKotlin' task (current target is 11)](https://stackoverflow.com/questions/73768537/task-react-native-gradle-plugincompilekotlin-failed-compilejava-task-curre)..._was solved with two answers that were given here:
package.jsonI prefixed the version with^, thenyarn install. Update “react native” version0.68.2for^0.68.2_I added the solve of this problem on stackoverflow too: https://stackoverflow.com/a/75907466/15748229_
I was able to make it work by doing the following:
replace
"react-native": "0.68.2"with"react-native": "^0.68.2"within
I am not very familiar with gradle, but that was the config that worked for me for now.
Facing the same issue on 0.70.1
Same issue. Can’t set the
-opt-in=kotlin.ExperimentalStdlibApicompiler flag. My kotlin version is1.6.10Edit I upgraded to Gradle 7.5.1 and it works./gradlew wrapper --gradle-version 7.5.1 --distribution-type=allI am also facing same issue. Not resolved with above solution. can you tell me what is the gradle version in gradle-wrapper.properties file in your case.
Which version of Kotlin are you using? Which libraries are you using? I suspect some of them are pulling in Kotlin and resulting in a conflicting version
same as @thangld322 @amirkhanzada-iinv
info Starting JS server… info Installing the app…
FAILURE: Build failed with an exception.
BUILD FAILED in 7s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
BUILD FAILED in 7s
@cortinico I am getting the similar error with new release of React Native 0.72.1. distributionUrl=https://services.gradle.org/distributions/gradle-8.0.1-all.zip
I’ve faced same issue, but after launching: react-native run-andoid - wait till end react-native start It started working normally
It works to me on RN 0.71 by upgrade Gradle to 7.5.1 on gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zipand then added this two lines of code on build.gradle
classpath('de.undercouch:gradle-download-task:5.0.1') classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20")I am also facing this issue with the react-native 0.68.2
Following this. I am facing the same issue.
+1 on this issue. I tried downgrading to java 8 … no go … doesn’t matter what Java env it’s running on.