react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Execution failed for task ':react-native-gradle-plugin:compileKotlin'.

Open tsaurav18 opened this issue 1 year ago • 35 comments

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(R) Core(TM) 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

tsaurav18 avatar Aug 14 '22 05:08 tsaurav18

No one replied this issue react native support. facing the same issues

soundaryamecse avatar Aug 16 '22 13:08 soundaryamecse

Issue and Reproduction Steps

Please provide a reproducer. Your build log is not sufficient. What is happening is that you're failing to compile some of the code inside the React Native Gradle Plugin. I can't tell the exact reason by just looking at your build log.

cortinico avatar Aug 16 '22 13:08 cortinico

:warning: Missing Reproducible Example
:information_source: It looks like your issue is missing a reproducible example. Please provide a Snack or a repository that demonstrates the issue you are reporting in a minimal, complete, and reproducible manner.

github-actions[bot] avatar Aug 16 '22 13:08 github-actions[bot]

Same issue here. Trying to upgrade react-native version from 0.63.4 to 0.69.4

mickeylam avatar Aug 25 '22 08:08 mickeylam

Receiving the same issue here upgrading react native from 0.67.3 to 0.69.3

EJ132 avatar Aug 30 '22 22:08 EJ132

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 add distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip in android/gradle/wrapper/gradle-wrapper.properties

and in android/build.gradle you have to add


classpath("com.android.tools.build:gradle:7.1.1")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:5.0.1")

for more information you can follow the React Native Upgrade Helper

hope this will work for you.

webdevchintan avatar Sep 06 '22 05:09 webdevchintan

Facing the same issue on 0.70.1

amirkhanzada51 avatar Sep 29 '22 09:09 amirkhanzada51

Same as @amirkhanzada-iinv

thangld322 avatar Oct 05 '22 11:10 thangld322

@amirkhanzada-iinv @thangld322 please provide a reproducer otherwise we're unable to support here.

cortinico avatar Oct 05 '22 17:10 cortinico

Same Problem, waiting for resolve solution.

SteveLai524 avatar Oct 25 '22 06:10 SteveLai524

same as @thangld322 @amirkhanzada-iinv

info Starting JS server... info Installing the app...

Task :react-native-gradle-plugin:compileKotlin FAILED 1 actionable task: 1 executed

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':react-native-gradle-plugin:compileKotlin'.

Failed to query the value of task ':react-native-gradle-plugin:compileKotlin' property 'compilerRunner$kotlin_gradle_plugin'. Kotlin could not find the required JDK tools in the Java installation. Make sure Kotlin compilation is running on a JDK, not JRE.

  • 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 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.

  • What went wrong: Execution failed for task ':react-native-gradle-plugin:compileKotlin'.

Failed to query the value of task ':react-native-gradle-plugin:compileKotlin' property 'compilerRunner$kotlin_gradle_plugin'. Kotlin could not find the required JDK tools in the Java installation. Make sure Kotlin compilation is running on a JDK, not JRE.

  • 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 7s

willysxw avatar Nov 01 '22 22:11 willysxw

+1 on this issue. I tried downgrading to java 8 .. no go .. doesn't matter what Java env it's running on.

flyandi avatar Nov 03 '22 00:11 flyandi

I have tried it to compile a release package, and it has not reproduced.

SteveLai524 avatar Nov 03 '22 01:11 SteveLai524

@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

info Starting JS server...
* daemon not running; starting now at tcp:5037
* daemon started successfully
info Launching emulator...
error Failed to launch emulator. Reason: Could not start emulator within 30 seconds..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

> Task :react-native-gradle-plugin:compileKotlin

> Task :react-native-gradle-plugin:compileKotlin FAILED
1 actionable task: 1 executed
e: C:\Work\upgrade\truckjunctionnew\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\tasks\BundleHermesCTask.kt: (137, 11): This declaration is experimental and its usage must be marked with '@kotlin.ExperimentalStdlibApi' or '@OptIn(kotlin.ExperimentalStdlibApi::class)'

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 1m 46s

agrittiwari avatar Nov 04 '22 05:11 agrittiwari

e: C:\Work\upgrade\truckjunctionnew\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\tasks\BundleHermesCTask.kt: (137, 11): This declaration is experimental and its usage must be marked with '@kotlin.ExperimentalStdlibApi' or '@OptIn(kotlin.ExperimentalStdlibApi::class)'

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

cortinico avatar Nov 07 '22 18:11 cortinico

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(R) Core(TM) 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

Try:

rm -rf ./node_modules
yarn
npm run android

RamboLouis avatar Nov 08 '22 03:11 RamboLouis

Following this. I am facing the same issue.

Following this. I am facing the same issue.

I am also facing this issue with the react-native 0.68.2

andre-luiz1997 avatar Nov 08 '22 17:11 andre-luiz1997

Following this. I am facing the same issue.

I am also facing this issue with the react-native 0.68.2

Same issue here. In package.json I prefixed the version with ^, then yarn install and it started working.

"react-native": "^0.68.2"

kwyg avatar Nov 08 '22 18:11 kwyg

Bunu ister. Aynı sorunla karşı karşıyayım.

Ayrıca bu sorunla tepki-yerel 0.68.2 ile karşı karşıyayım.

Burada da aynı sorun. package.json'da uygulamada , başladıktan sonra katıldım ve yayınlandı.^yarn install

"react-native": "^0.68.2"

Thank you so much

BilalKucuk491 avatar Nov 09 '22 06:11 BilalKucuk491

Following this. I am facing the same issue.

I am also facing this issue with the react-native 0.68.2

Same issue here. In package.json I prefixed the version with ^, then yarn install and it started working.

"react-native": "^0.68.2"

I 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.

Jayashreekm avatar Nov 09 '22 07:11 Jayashreekm

Following this. I am facing the same issue.

I am also facing this issue with the react-native 0.68.2

Same issue here. In package.json I prefixed the version with ^, then yarn install and it started working. "react-native": "^0.68.2"

I 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.

My Gradle version is 7.3.3.

kwyg avatar Nov 09 '22 09:11 kwyg

I was able to make it work by doing the following:

  • in package.json:

replace "react-native": "0.68.2" with
"react-native": "^0.68.2"

  • in android/build.gradle:

within

buildscript {
         ...
         ext {
                ...
                compileSdkVersion: '33'
                targetSdkVersion: '33'
                kotlinVersion: '1.6.20'
                ...
         }
         ...
         dependencies {
                  ...
                classpath('com.android.tools.build:gradle:7.3.0')
                classpath('com.facebook.react:react-native-gradle-plugin')
                classpath('de.undercouch:gradle-download-task:5.0.1')
                classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20")
         }
}

I am not very familiar with gradle, but that was the config that worked for me for now.

andre-luiz1997 avatar Nov 09 '22 11:11 andre-luiz1997

I have the same issue

amirbhz86 avatar Nov 12 '22 07:11 amirbhz86

I'm having the same issue, the solutions above don't work for me..

erenerogullari avatar Nov 14 '22 20:11 erenerogullari

same here

hamdidamar avatar Nov 15 '22 11:11 hamdidamar

same here

kumkao avatar Nov 16 '22 15:11 kumkao

@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

info Starting JS server...
* daemon not running; starting now at tcp:5037
* daemon started successfully
info Launching emulator...
error Failed to launch emulator. Reason: Could not start emulator within 30 seconds..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

> Task :react-native-gradle-plugin:compileKotlin

> Task :react-native-gradle-plugin:compileKotlin FAILED
1 actionable task: 1 executed
e: C:\Work\upgrade\truckjunctionnew\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\tasks\BundleHermesCTask.kt: (137, 11): This declaration is experimental and its usage must be marked with '@kotlin.ExperimentalStdlibApi' or '@OptIn(kotlin.ExperimentalStdlibApi::class)'

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 1m 46s

same issue, any update?

alanBriceno avatar Nov 18 '22 08:11 alanBriceno

As it worked for me, in <PROJECT>/android/gradle/gradle/wrapper/gradle-wrapper.properties i changed the line distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip by distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip.

in android/build.gradle:

buildscript {
         ...
         ext {
                ...
                compileSdkVersion = 33
                targetSdkVersion = 33
                kotlinVersion = '1.6.20'
                ...
         }
         ...
         dependencies {
                  ...
                classpath('com.android.tools.build:gradle:7.3.0')
                classpath('com.facebook.react:react-native-gradle-plugin')
                classpath('de.undercouch:gradle-download-task:5.0.1')
                classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20")
         }
}

in the end in android/app/src/main/AndroidManifest.xml:

added the package

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="<com.<YOUR_PROJECT>" 
>

completed, opened Android Studio and synchronized the gradle...

hope to help

paulopgss avatar Nov 18 '22 19:11 paulopgss

Same issue. Can't set the -opt-in=kotlin.ExperimentalStdlibApi compiler flag. My kotlin version is 1.6.10 Edit I upgraded to Gradle 7.5.1 and it works ./gradlew wrapper --gradle-version 7.5.1 --distribution-type=all

ste7en avatar Nov 23 '22 09:11 ste7en