Dha*_*aja 17 java android gradle react-native java-11
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 936 file(s) to forward-jetify. Using 12 workers...
info JS server already running.
info Installing the app...
> Task :react-native-gradle-plugin:compileKotlin FAILED
'compileJava' task (current target is 1.8) and 'compileKotlin' task (current target is 11) jvm target compatibility should be set to the same Java version.
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 4s
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 4s
at makeError (C:\Users\dhanp\React native projects\test3\ProjectName\node_modules\execa\index.js:174:9)
at C:\Users\dhanp\React native projects\test3\ProjectName\node_modules\execa\index.js:278:16
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async runOnAllDevices (C:\Users\dhanp\React native projects\test3\ProjectName\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (C:\Users\dhanp\React native projects\test3\ProjectName\node_modules\@react-native-community\cli\build\index.js:192:9)
info Run CLI with --verbose flag for more details
Run Code Online (Sandbox Code Playgroud)
我见过涉及更改 classpath() 和分发 URL 的解决方案,但我已经完成了。
从我的 build.gradle 文件:
dependencies {
classpath("com.android.tools.build:gradle:7.2.1")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:4.1.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Run Code Online (Sandbox Code Playgroud)
来自 gradle 包装器
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Run Code Online (Sandbox Code Playgroud)
这些都不能修复错误,此外,我注意到运行 gradlew clean 也会引发相同的错误
> Task :react-native-gradle-plugin:compileKotlin FAILED
'compileJava' task (current target is 1.8) and 'compileKotlin' task (current target is 11) jvm target compatibility should be set to the same Java version.
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 4s
1 actionable task: 1 executed
Run Code Online (Sandbox Code Playgroud)
我还尝试将以下代码添加到 build.gradle 文件中
android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}
}
Run Code Online (Sandbox Code Playgroud)
请帮我解决这个问题,我以前使用过 EXPO CLI,一切都运行良好,所有这一切都是为了学习 React-native CLI。
小智 16
我遇到了同样的问题,为了解决这个问题,我在 gradle-wrapper.properties 文件中进行了更改
前:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
Run Code Online (Sandbox Code Playgroud)
后:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
Run Code Online (Sandbox Code Playgroud)
我面临同样的问题,所有 Java 包都已安装或完美同步,但 kotlin 包未同步,它会引发 kotlin 编译错误。
\n我按照This在 Android Studio 上安装 kotlin 包。
\n\n\nAndroid Studio \xe2\x86\x92 Preferences\xe2\x80\xa6 \xe2\x86\x92Plugins \xe2\x86\x92 Browse Repository \xe2\x86\x92 在搜索中输入 \xe2\x80\x9cKotlin\xe2\x80\x9d框\xe2\x86\x92 安装
\n
之后,您需要从中删除该项目的缓存
\n\n\n文件 -> 使缓存无效 -> 无效并重新启动。
\n
之后,当您的项目重新打开并成功同步时,请从Build -> Clean Project
.
之后kotlin的所有包就完美安装了。
\n 归档时间: |
|
查看次数: |
34521 次 |
最近记录: |