ToB企服应用市场:ToB评测及商务社交产业平台

标题: 【错误记载】Android Studio 中 Kotlin 版本报错 ( Module was compiled wi [打印本页]

作者: tsx81429    时间: 2024-6-15 00:43
标题: 【错误记载】Android Studio 中 Kotlin 版本报错 ( Module was compiled wi
一、报错信息



在 Android Studio 中 , 编译应用 , 报如下错误 :
  1. C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.6.0/7857e365f925cfa060f941c1357cda1f8790502c/kotlin-stdlib-common-1.6.0.jar!/META-INF/kotlin-stdlib-common.kotlin_module:
  2. Module was compiled with an incompatible version of Kotlin.
  3. The binary version of its metadata is 1.6.0, expected version is 1.1.13.
复制代码

这个报错问题 , 出现了十几次 ;

详细报错信息如下 : 下面的报错信息 , 仅做参考 , 就不要点开了 ;
  1. > Task :app:compileDebugKotlin FAILEDw: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:    C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.5.30/5fd47535cc85f9e24996f939c2de6583991481b0/kotlin-stdlib-jdk8-1.5.30.jar (version 1.5)    C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.30/525f5a7fa6d7790a571c07dd24214ed2dda352fe/kotlin-stdlib-jdk7-1.5.30.jar (version 1.5)    C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.0/a40b8b22529b733892edf4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar (version 1.6)    C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.6.0/7857e365f925cfa060f941c1357cda1f8790502c/kotlin-stdlib-common-1.6.0.jar (version 1.6)w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpathe: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errorse: C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.6.0/7857e365f925cfa060f941c1357cda1f8790502c/kotlin-stdlib-common-1.6.0.jar!/META-INF/kotlin-stdlib-common.kotlin_module:
  2. Module was compiled with an incompatible version of Kotlin.
  3. The binary version of its metadata is 1.6.0, expected version is 1.1.13.
  4. e: C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.30/525f5a7fa6d7790a571c07dd24214ed2dda352fe/kotlin-stdlib-jdk7-1.5.30.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.13.e: C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.5.30/5fd47535cc85f9e24996f939c2de6583991481b0/kotlin-stdlib-jdk8-1.5.30.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.13.e: C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.0/a40b8b22529b733892edf4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.Runtime JAR files in the classpath should have the same version. These files were found in the classpath:    C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.5.30/5fd47535cc85f9e24996f939c2de6583991481b0/kotlin-stdlib-jdk8-1.5.30.jar (version 1.5)    C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.30/525f5a7fa6d7790a571c07dd24214ed2dda352fe/kotlin-stdlib-jdk7-1.5.30.jar (version 1.5)    C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.0/a40b8b22529b733892edf4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar (version 1.6)    C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.6.0/7857e365f925cfa060f941c1357cda1f8790502c/kotlin-stdlib-common-1.6.0.jar (version 1.6)e: C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-android/1.5.2/d246a704a55b7bddb79407cce4348890eaa341d9/kotlinx-coroutines-android-1.5.2.jar!/META-INF/kotlinx-coroutines-android.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.13.e: C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core-jvm/1.5.2/f4cc07a50437659e0043e7da762809a46932b6a0/kotlinx-coroutines-core-jvm-1.5.2.jar!/META-INF/kotlinx-coroutines-core.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.13.e: C:/Users/octop/.gradle/caches/transforms-3/2d2e05a2754ff6e110d0373147158883/transformed/navigation-fragment-2.4.1-api.jar!/META-INF/navigation-fragment_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.e: C:/Users/octop/.gradle/caches/transforms-3/7c8d0ea965780acf266bbf51684cf083/transformed/navigation-runtime-2.4.1-api.jar!/META-INF/navigation-runtime_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.e: C:/Users/octop/.gradle/caches/transforms-3/98a12fce22bb35efa781271d8241e273/transformed/core-ktx-1.7.0-api.jar!/META-INF/core-ktx_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.13.e: C:/Users/octop/.gradle/caches/transforms-3/a30274fc0e0526fe1ef8c0b3cd696552/transformed/fragment-ktx-1.4.1-api.jar!/META-INF/fragment-ktx_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.13.e: C:/Users/octop/.gradle/caches/transforms-3/b3e72646352669a2c158a12247e912da/transformed/slidingpanelayout-1.2.0-api.jar!/META-INF/slidingpanelayout_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.e: C:/Users/octop/.gradle/caches/transforms-3/b812a08bf56bf9d544c39f2d2daffce7/transformed/navigation-ui-2.4.1-api.jar!/META-INF/navigation-ui_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.e: C:/Users/octop/.gradle/caches/transforms-3/bbf2426cb1f6c0ebbc959e0eb199649d/transformed/fragment-1.4.1-api.jar!/META-INF/fragment_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.13.e: C:/Users/octop/.gradle/caches/transforms-3/d12e05eecb6d4d83cbc249be744f1fb1/transformed/navigation-common-2.4.1-api.jar!/META-INF/navigation-common_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.e: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentA.kt: (9, 28): Class 'androidx.navigation.Navigation' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/transforms-3/7c8d0ea965780acf266bbf51684cf083/transformed/navigation-runtime-2.4.1-api.jar!/androidx/navigation/Navigation.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentA.kt: (18, 15): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.0/a40b8b22529b733892edf4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar!/kotlin/Unit.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentA.kt: (30, 15): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.0/a40b8b22529b733892edf4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar!/kotlin/Unit.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentA.kt: (32, 16): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.0/a40b8b22529b733892edf4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar!/kotlin/Unit.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentA.kt: (34, 41): Unresolved reference: applye: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentA.kt: (36, 22): Unresolved reference: putStringe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentA.kt: (37, 22): Unresolved reference: putInte: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentA.kt: (41, 33): Class 'androidx.navigation.Navigation' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/transforms-3/7c8d0ea965780acf266bbf51684cf083/transformed/navigation-runtime-2.4.1-api.jar!/androidx/navigation/Navigation.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentA.kt: (41, 44): Class 'androidx.navigation.NavController' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/transforms-3/7c8d0ea965780acf266bbf51684cf083/transformed/navigation-runtime-2.4.1-api.jar!/androidx/navigation/NavController.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentA.kt: (43, 13): Class 'androidx.navigation.NavController' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/transforms-3/7c8d0ea965780acf266bbf51684cf083/transformed/navigation-runtime-2.4.1-api.jar!/androidx/navigation/NavController.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentA.kt: (43, 27): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.0/a40b8b22529b733892edf4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar!/kotlin/Unit.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentB.kt: (10, 28): Class 'androidx.navigation.Navigation' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/transforms-3/7c8d0ea965780acf266bbf51684cf083/transformed/navigation-runtime-2.4.1-api.jar!/androidx/navigation/Navigation.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentB.kt: (21, 15): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.6.0/7857e365f925cfa060f941c1357cda1f8790502c/kotlin-stdlib-common-1.6.0.jar!/META-INF/kotlin-stdlib-common.kotlin_module:
  5. Module was compiled with an incompatible version of Kotlin.
  6. The binary version of its metadata is 1.6.0, expected version is 1.1.13.
  7. The class is loaded from C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.0/a40b8b22529b733892edf4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar!/kotlin/Unit.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentB.kt: (22, 20): Unresolved reference: lete: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentB.kt: (23, 13): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.0/a40b8b22529b733892edf4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar!/kotlin/Unit.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentB.kt: (23, 20): Unresolved reference: ite: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentB.kt: (24, 13): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.0/a40b8b22529b733892edf4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar!/kotlin/Unit.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentB.kt: (24, 19): Unresolved reference: ite: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentB.kt: (39, 15): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.0/a40b8b22529b733892edf4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar!/kotlin/Unit.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentB.kt: (41, 16): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.0/a40b8b22529b733892edf4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar!/kotlin/Unit.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentB.kt: (48, 33): Class 'androidx.navigation.Navigation' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/transforms-3/7c8d0ea965780acf266bbf51684cf083/transformed/navigation-runtime-2.4.1-api.jar!/androidx/navigation/Navigation.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentB.kt: (48, 44): Class 'androidx.navigation.NavController' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/transforms-3/7c8d0ea965780acf266bbf51684cf083/transformed/navigation-runtime-2.4.1-api.jar!/androidx/navigation/NavController.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentB.kt: (50, 13): Class 'androidx.navigation.NavController' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/transforms-3/7c8d0ea965780acf266bbf51684cf083/transformed/navigation-runtime-2.4.1-api.jar!/androidx/navigation/NavController.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\FragmentB.kt: (50, 27): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.0/a40b8b22529b733892edf4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar!/kotlin/Unit.class
  8. e: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\MainActivity.kt: (5, 28):
  9. Class 'androidx.navigation.Navigation' was compiled with an incompatible version of Kotlin.
  10. The binary version of its metadata is 1.6.0, expected version is 1.1.13.
  11. The class is loaded from C:/Users/octop/.gradle/caches/transforms-3/7c8d0ea965780acf266bbf51684cf083/transformed/navigation-runtime-2.4.1-api.jar!/androidx/navigation/Navigation.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\MainActivity.kt: (6, 31): Class 'androidx.navigation.ui.NavigationUI' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/transforms-3/b812a08bf56bf9d544c39f2d2daffce7/transformed/navigation-ui-2.4.1-api.jar!/androidx/navigation/ui/NavigationUI.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\MainActivity.kt: (10, 15): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.30/525f5a7fa6d7790a571c07dd24214ed2dda352fe/kotlin-stdlib-jdk7-1.5.30.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.0/a40b8b22529b733892edf4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar!/kotlin/Unit.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\MainActivity.kt: (11, 9): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.0/a40b8b22529b733892edf4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar!/kotlin/Unit.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\MainActivity.kt: (15, 29): Class 'androidx.navigation.NavController' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/transforms-3/7c8d0ea965780acf266bbf51684cf083/transformed/navigation-runtime-2.4.1-api.jar!/androidx/navigation/NavController.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\MainActivity.kt: (16, 9): Class 'androidx.navigation.ui.NavigationUI' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/transforms-3/b812a08bf56bf9d544c39f2d2daffce7/transformed/navigation-ui-2.4.1-api.jar!/androidx/navigation/ui/NavigationUI.classC:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.5.30/5fd47535cc85f9e24996f939c2de6583991481b0/kotlin-stdlib-jdk8-1.5.30.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.13.C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.0/a40b8b22529b733892edf4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.e: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\MainActivity.kt: (16, 22): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-android/1.5.2/d246a704a55b7bddb79407cce4348890eaa341d9/kotlinx-coroutines-android-1.5.2.jar!/META-INF/kotlinx-coroutines-android.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.0/a40b8b22529b733892edf4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar!/kotlin/Unit.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\MainActivity.kt: (16, 22): Class 'androidx.navigation.NavController' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core-jvm/1.5.2/f4cc07a50437659e0043e7da762809a46932b6a0/kotlinx-coroutines-core-jvm-1.5.2.jar!/META-INF/kotlinx-coroutines-core.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/transforms-3/7c8d0ea965780acf266bbf51684cf083/transformed/navigation-runtime-2.4.1-api.jar!/androidx/navigation/NavController.classC:/Users/octop/.gradle/caches/transforms-3/2d2e05a2754ff6e110d0373147158883/transformed/navigation-fragment-2.4.1-api.jar!/META-INF/navigation-fragment_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.e: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\MainActivity.kt: (16, 22): Class 'androidx.navigation.ui.AppBarConfiguration' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.C:/Users/octop/.gradle/caches/transforms-3/7c8d0ea965780acf266bbf51684cf083/transformed/navigation-runtime-2.4.1-api.jar!/META-INF/navigation-runtime_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.C:/Users/octop/.gradle/caches/transforms-3/98a12fce22bb35efa781271d8241e273/transformed/core-ktx-1.7.0-api.jar!/META-INF/core-ktx_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/transforms-3/b812a08bf56bf9d544c39f2d2daffce7/transformed/navigation-ui-2.4.1-api.jar!/androidx/navigation/ui/AppBarConfiguration.classe: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\MainActivity.kt: (16, 60): Class 'androidx.navigation.NavController' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.C:/Users/octop/.gradle/caches/transforms-3/a30274fc0e0526fe1ef8c0b3cd696552/transformed/fragment-ktx-1.4.1-api.jar!/META-INF/fragment-ktx_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.13.The class is loaded from C:/Users/octop/.gradle/caches/transforms-3/7c8d0ea965780acf266bbf51684cf083/transformed/navigation-runtime-2.4.1-api.jar!/androidx/navigation/NavController.classC:/Users/octop/.gradle/caches/transforms-3/b3e72646352669a2c158a12247e912da/transformed/slidingpanelayout-1.2.0-api.jar!/META-INF/slidingpanelayout_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.C:/Users/octop/.gradle/caches/transforms-3/b812a08bf56bf9d544c39f2d2daffce7/transformed/navigation-ui-2.4.1-api.jar!/META-INF/navigation-ui_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.C:/Users/octop/.gradle/caches/transforms-3/bbf2426cb1f6c0ebbc959e0eb199649d/transformed/fragment-1.4.1-api.jar!/META-INF/fragment_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.13.C:/Users/octop/.gradle/caches/transforms-3/d12e05eecb6d4d83cbc249be744f1fb1/transformed/navigation-common-2.4.1-api.jar!/META-INF/navigation-common_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.13.
复制代码




二、问题分析



核心报错信息如下 :
Module was compiled with an incompatible version of Kotlin.
The binary version of its metadata is 1.6.0, expected version is 1.1.13.

大概含义就是用错了 Kotlin 语言的版本 ;
模块是用不兼容的Kotlin版本编译的。
其元数据的二进制版本为1.6.0,预期版本为1.1.13。

再检察一个具体的错误 :
  1. The class is loaded from C:/Users/octop/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.0/a40b8b22529b733892edf4b73468ce598bb17f04/kotlin-stdlib-1.6.0.jar!/kotlin/Unit.class
  2. e: D:\002_Project\002_Android_Learn\Navigation\app\src\main\java\kim\hsl\nav\MainActivity.kt: (5, 28):
  3. Class 'androidx.navigation.Navigation' was compiled with an incompatible version of Kotlin.
  4. The binary version of its metadata is 1.6.0, expected version is 1.1.13.
复制代码
分析上述错误 :
Class ‘androidx.navigation.Navigation’ was compiled with an incompatible version of Kotlin.
The binary version of its metadata is 1.6.0, expected version is 1.1.13.
类的androidx.navigation。“导航”是用不兼容的Kotlin版本编译的。
其元数据的二进制版本为1.6.0,预期版本为1.1.13。

该 Android 项目中调用了 androidx.navigation.Navigation 库 , 该库使用的 Kotlin 版本是 1.6.0 , 你用的 Kotlin 版本只能 高于该 Kotlin 版本 ;




三、办理方案



在 编译依靠 中 , 添加 Kotlin 语言 Gradle 插件 , 高于 上面报错提示的 1.6.0 版本即可 ;
  1. classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20'
复制代码

1、低版本 Gradle 设置


假如使用的是 低版本的 Gradle 进行构建 , 则是在 根目录下的 buildscript / dependencies 中添加 如下依靠 ;
  1. classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20'
复制代码
添加后的完备代码如下 :
  1. buildscript {    repositories {        google()        mavenCentral()        jcenter()        maven {            url 'https://maven.aliyun.com/repository/public/'        }        maven{            url 'https://maven.aliyun.com/repository/google/'        }    }    dependencies {        classpath "com.android.tools.build:gradle:7.3.1"        classpath 'androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0-alpha06'        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20'
  2.         // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files    }}
复制代码

2、高版本 Gradle 设置


假如你当前使用的是 高版本的 Gradle 构建工具 , 那么必要在 根目录下的 build.gradle 中的 plugins 中添加
  1. id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
复制代码
插件的依靠 ;
完备的代码如下 :
  1. // Top-level build file where you can add configuration options common to all sub-projects/modules.plugins {    id 'com.android.application' version '7.3.1' apply false    id 'com.android.library' version '7.3.1' apply false    id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
  2.     id 'androidx.navigation.safeargs' version '2.3.0-alpha06' apply false}
复制代码
对应的 Maven 库设置在 settings.gradle 构建脚本中 , 代码如下 :
  1. pluginManagement {
  2.     repositories {
  3.         gradlePluginPortal()
  4.         google()
  5.         mavenCentral()
  6.         jcenter()
  7.         maven {
  8.             url 'https://maven.aliyun.com/repository/public/'
  9.         }
  10.         maven{
  11.             url 'https://maven.aliyun.com/repository/google/'
  12.         }
  13.     }
  14. }
复制代码
这里发起把 jcenter 和 阿里云的源都设置进去 , 多设置一些 , 总不会出错 ;

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4