我有一个 React Native
0.73.2
并致力于 MoEngage 集成。安装的 MoEngage 的 React Native 版本是 8.6.0
,而 android sdk 版本是 com.moengage:moe-android-sdk:12.10.02
。
我的 React Native 项目正在使用 Java 17,编译应用程序时出现错误:
> 'compileDebugJavaWithJavac' task (current target is 17) and 'compileDebugKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version. Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain * Try:
所以,我更新了我的(应用程序)build.gradle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
问题仍然存在,我仍然无法编译应用程序。
我遇到了同样的问题,这对我有用:
构建.gradle
android {
...
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
if (agpVersion.tokenize('.')[0].toInteger() < 8) {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
}
参考资料: