我是新的反应本机开发使用Mac M1。当我运行时,我得到了下面的错误。
我真的不知道如何纠正这个错误,感谢任何人能帮忙,再次感谢!
> Task :react-native-gradle-plugin:compileKotlin
'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.
> Task :react-native-gradle-plugin:compileKotlin FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8/userguide/command_line_interface.html#sec:command_line_warnings
e: /Users/fuzhonghan/Documents/AwesomeAndroidProject/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (28, 33): Unresolved reference: replaceFirstChar
e: /Users/fuzhonghan/Documents/AwesomeAndroidProject/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (28, 52): Unresolved reference: it
e: /Users/fuzhonghan/Documents/AwesomeAndroidProject/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (252, 16): Unresolved reference: lowercase
e: /Users/fuzhonghan/Documents/AwesomeAndroidProject/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt: (13, 38): Unresolved reference: lowercase
e: /Users/fuzhonghan/Documents/AwesomeAndroidProject/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt: (15, 57): Unresolved reference: lowercase
e: /Users/fuzhonghan/Documents/AwesomeAndroidProject/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt: (18, 54): Unresolved reference: lowercase
e: /Users/fuzhonghan/Documents/AwesomeAndroidProject/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt: (19, 52): Unresolved reference: lowercase
e: /Users/fuzhonghan/Documents/AwesomeAndroidProject/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt: (190, 27): Type mismatch: inferred type is Unit but CharSequence was expected
e: /Users/fuzhonghan/Documents/AwesomeAndroidProject/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt: (190, 44): Unresolved reference: replaceFirstChar
e: /Users/fuzhonghan/Documents/AwesomeAndroidProject/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt: (190, 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
命令行javac -版本结果.
javac 11.0.15
命令行java -版本结果.
openjdk 11.0.15 2022-04-19 LTS
OpenJDK Runtime Environment Zulu11.56+19-CA (build 11.0.15+10-LTS)
OpenJDK 64-Bit Server VM Zulu11.56+19-CA (build 11.0.15+10-LTS, mixed mode)
gradle-wrapper.properties
的含量在.(我已经将gradle版本从7.1.1降至6.8,因为插件maven
已从第7级中删除。)
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
发布于 2022-07-12 15:21:02
我从这个StackOverflow答案:更新OpenJDK 11中解决了我的Gradle插件错误
我在PowerShell中使用巧克力更新了JDK,并输入了以下管理权限:
choco install -y openjdk11
然后,我将project/android/app/build.gradle
中的Gradle版本从6.9更新到7.4.2。
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
最近,我将自己的ReactiveNative69.1升级到69.1,因此我研究了需要使用哪个版本的Gradle。我找到了这份文件。
Android的先决条件是
接下来,在项目build.gradle
中,我将构建工具更改为classpath("com.android.tools.build:gradle:7.2.1")
。
我更新到了最新版本的AndroidStudio2021.1.1或更高版本。
我不再有compileKotlin和compileJava错误。
https://stackoverflow.com/questions/72906105
复制相似问题