我刚刚在我的Android项目中启用了Kotlin,我偶然发现了一个警告.在第二次构建(Build - > Rebuild Project)之后,此警告显示在Messages下:
Warning:Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
~/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.2.10/85fe1811f3e586d0cc53aba1394d8089f1862215/kotlin-stdlib-jdk8-1.2.10.jar (version 1.2)
~/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-reflect/1.2.10/19bc012f8c4cd6b705bd6512263777cc19bcf259/kotlin-reflect-1.2.10.jar (version 1.2)
/Applications/Android Studio.app/Contents/gradle/m2repository/org/jetbrains/kotlin/kotlin-stdlib-jre7/1.1.51/kotlin-stdlib-jre7-1.1.51.jar (version 1.1)
~/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.2.10/cfe8b616b3bf0811ef70863c86b745a2e767a66e/kotlin-stdlib-jdk7-1.2.10.jar (version 1.2)
~/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.2.10/b9bf650516989595a5390e5a54181e16347208ac/kotlin-stdlib-1.2.10.jar (version 1.2)
Run Code Online (Sandbox Code Playgroud)
看起来第二个版本包含过时kotlin-stdlib-jre7-1.1.51.jar
的缓存.在干净的构建(构建 - >清理项目)之后,警告消失,下一个重建项目再次启动它.
我正在使用Android Studio 3.0.1并且我明确地将Kotlin依赖项包含在版本中:
的build.gradle
buildscript {
ext {
// shared build properties
kotlin_version = '1.2.10'
buildToolsVersion = '27.0.2'
minSdkVersion = 15
targetSdkVersion = 27
compileSdkVersion = 27
}
repositories {
jcenter()
google()
}
dependencies {
classpath …
Run Code Online (Sandbox Code Playgroud) 说我花了大约 32 个小时还算轻描淡写。我一直在尝试在由 Expo SDK 44 提供支持的 React Native 项目中启用 Kotlin。
\n我一直在尝试在互联网上找到的所有方法,但总是在 EAS 的 Gradle 阶段出现错误(使用 运行它eas build --profile development --platform android
)。
这是我的配置:
\n为了简洁起见,我省略了代码。如果您需要更多背景信息,请告诉我
\n应用程序\\android\\build.gradle:
\nbuildscript {\n ext {\n buildToolsVersion = "30.0.2"\n minSdkVersion = 21\n compileSdkVersion = 31\n targetSdkVersion = 31\n kotlinVersion = "1.4.11"\n }\n repositories {\n google()\n mavenCentral()\n jcenter()\n }\n dependencies {\n classpath("com.android.tools.build:gradle:4.1.0")\n classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")\n \n // NOTE: Do not place your application dependencies here; they belong\n // in the individual module build.gradle …
Run Code Online (Sandbox Code Playgroud)