gpt4 book ai didi

android - Kotlin IllegalStateException : Resource not found in classpath: kotlin/. kotlin_string_table

转载 作者:行者123 更新时间:2023-12-02 13:00:59 24 4
gpt4 key购买 nike

我正在尝试在我的 Android 应用程序中使用 Kotlin,但在调用扩展函数时遇到了麻烦。该应用程序立即崩溃并显示以下堆栈跟踪:

04-23 13:31:22.415  32606-32606/com.example.kotlin.test E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.kotlin.test, PID: 32606
java.lang.ExceptionInInitializerError
at org.jetbrains.kotlin.load.kotlin.reflect.RuntimeModuleData$Companion.create(RuntimeModuleData.kt:34)
at kotlin.reflect.jvm.internal.InternalPackage$moduleByClassLoader$cff17278.getOrCreateModule(moduleByClassLoader.kt:54)
at kotlin.reflect.jvm.internal.KClassImpl$descriptor$1.invoke(KClassImpl.kt:31)
at kotlin.reflect.jvm.internal.KClassImpl$descriptor$1.invoke(KClassImpl.kt:26)
at kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.get(ReflectProperties.java:84)
at kotlin.reflect.jvm.internal.KClassImpl.getDescriptor(KClassImpl.kt)
at kotlin.reflect.jvm.internal.KClassImpl.getScope(KClassImpl.kt:43)
at kotlin.reflect.jvm.internal.KClassImpl.getProperties(KClassImpl.kt:84)
at kotlin.reflect.jvm.internal.KClassImpl.getProperties(KClassImpl.kt:72)
at kotlin.reflect.ReflectPackage$KClassExtensions$6beb0f9b.getDeclaredProperties(KClassExtensions.kt:25)
at kotlin.reflect.ReflectPackage.getDeclaredProperties(KClassExtensions.kt:1)
at com.example.test.kotlin.api.model.DatabaseObject$$TImpl.deflate(DatabaseObject.kt:40)
at com.example.test.kotlin.api.model.impl.Model.deflate(Model.kt)
at com.example.test.kotlin.api.model.impl.Model.<init>(Model.kt:28)
at com.example.test.kotlin.api.model.impl.TestModel.<init>(TestModel.kt:23)
at com.example.app.TestModelIndexFragment.onCreate(TestModelIndexFragment.java:122)
at android.support.v4.app.Fragment.performCreate(Fragment.java:1763)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:915)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1136)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1499)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220)
at android.app.Activity.performStart(Activity.java:5949)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
at android.app.ActivityThread.access$900(ActivityThread.java:147)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
Caused by: java.lang.IllegalStateException: Built-in library initialization failed. Please ensure you have kotlin-runtime.jar in the classpath: java.lang.IllegalStateException: Resource not found in classpath: kotlin/.kotlin_string_table
at org.jetbrains.kotlin.builtins.KotlinBuiltIns.initialize(KotlinBuiltIns.java:75)
at org.jetbrains.kotlin.builtins.KotlinBuiltIns.getInstance(KotlinBuiltIns.java:93)
at org.jetbrains.kotlin.platform.JavaToKotlinClassMapBuilder.init(JavaToKotlinClassMapBuilder.java:35)
at org.jetbrains.kotlin.platform.JavaToKotlinClassMap.<init>(JavaToKotlinClassMap.java:44)
at org.jetbrains.kotlin.platform.JavaToKotlinClassMap.<clinit>(JavaToKotlinClassMap.java:35)
            at org.jetbrains.kotlin.load.kotlin.reflect.RuntimeModuleData$Companion.create(RuntimeModuleData.kt:34)
            at kotlin.reflect.jvm.internal.InternalPackage$moduleByClassLoader$cff17278.getOrCreateModule(moduleByClassLoader.kt:54)
            at kotlin.reflect.jvm.internal.KClassImpl$descriptor$1.invoke(KClassImpl.kt:31)
            at kotlin.reflect.jvm.internal.KClassImpl$descriptor$1.invoke(KClassImpl.kt:26)
            at kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.get(ReflectProperties.java:84)
            at kotlin.reflect.jvm.internal.KClassImpl.getDescriptor(KClassImpl.kt)
            at kotlin.reflect.jvm.internal.KClassImpl.getScope(KClassImpl.kt:43)
            at kotlin.reflect.jvm.internal.KClassImpl.getProperties(KClassImpl.kt:84)
            at kotlin.reflect.jvm.internal.KClassImpl.getProperties(KClassImpl.kt:72)
            at kotlin.reflect.ReflectPackage$KClassExtensions$6beb0f9b.getDeclaredProperties(KClassExtensions.kt:25)
            at kotlin.reflect.ReflectPackage.getDeclaredProperties(KClassExtensions.kt:1)
            at com.example.test.kotlin.api.model.DatabaseObject$$TImpl.deflate(DatabaseObject.kt:40)
            at com.example.test.kotlin.api.model.impl.Model.deflate(Model.kt)
            at com.example.test.kotlin.api.model.impl.Model.<init>(Model.kt:28)
            at com.example.test.kotlin.api.model.impl.TestModel.<init>(TestModel.kt:23)
            at com.example.app.TestModelIndexFragment.onCreate(TestModelIndexFragment.java:122)
            at android.support.v4.app.Fragment.performCreate(Fragment.java:1763)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:915)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1136)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1499)
            at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
            at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220)
            at android.app.Activity.performStart(Activity.java:5949)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
            at android.app.ActivityThread.access$900(ActivityThread.java:147)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
Caused by: java.lang.IllegalStateException: Resource not found in classpath: kotlin/.kotlin_string_table
at org.jetbrains.kotlin.builtins.BuiltinsPackageFragment.getStream(BuiltinsPackageFragment.kt:86)
at org.jetbrains.kotlin.builtins.BuiltinsPackageFragment.<init>(BuiltinsPackageFragment.kt:55)
at org.jetbrains.kotlin.builtins.KotlinBuiltIns.<init>(KotlinBuiltIns.java:114)
at org.jetbrains.kotlin.builtins.KotlinBuiltIns.initialize(KotlinBuiltIns.java:70)
            at org.jetbrains.kotlin.builtins.KotlinBuiltIns.getInstance(KotlinBuiltIns.java:93)
            at org.jetbrains.kotlin.platform.JavaToKotlinClassMapBuilder.init(JavaToKotlinClassMapBuilder.java:35)
            at org.jetbrains.kotlin.platform.JavaToKotlinClassMap.<init>(JavaToKotlinClassMap.java:44)
            at org.jetbrains.kotlin.platform.JavaToKotlinClassMap.<clinit>(JavaToKotlinClassMap.java:35)
            at org.jetbrains.kotlin.load.kotlin.reflect.RuntimeModuleData$Companion.create(RuntimeModuleData.kt:34)
            at kotlin.reflect.jvm.internal.InternalPackage$moduleByClassLoader$cff17278.getOrCreateModule(moduleByClassLoader.kt:54)
            at kotlin.reflect.jvm.internal.KClassImpl$descriptor$1.invoke(KClassImpl.kt:31)
            at kotlin.reflect.jvm.internal.KClassImpl$descriptor$1.invoke(KClassImpl.kt:26)
            at kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.get(ReflectProperties.java:84)
            at kotlin.reflect.jvm.internal.KClassImpl.getDescriptor(KClassImpl.kt)
            at kotlin.reflect.jvm.internal.KClassImpl.getScope(KClassImpl.kt:43)
            at kotlin.reflect.jvm.internal.KClassImpl.getProperties(KClassImpl.kt:84)
            at kotlin.reflect.jvm.internal.KClassImpl.getProperties(KClassImpl.kt:72)
            at kotlin.reflect.ReflectPackage$KClassExtensions$6beb0f9b.getDeclaredProperties(KClassExtensions.kt:25)
            at kotlin.reflect.ReflectPackage.getDeclaredProperties(KClassExtensions.kt:1)
            at com.example.test.kotlin.api.model.DatabaseObject$$TImpl.deflate(DatabaseObject.kt:40)
            at com.example.test.kotlin.api.model.impl.Model.deflate(Model.kt)
            at com.example.test.kotlin.api.model.impl.Model.<init>(Model.kt:28)
            at com.example.test.kotlin.api.model.impl.TestModel.<init>(TestModel.kt:23)
            at com.example.app.TestModelIndexFragment.onCreate(TestModelIndexFragment.java:122)
            at android.support.v4.app.Fragment.performCreate(Fragment.java:1763)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:915)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1136)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1499)
            at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
            at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220)
            at android.app.Activity.performStart(Activity.java:5949)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
            at android.app.ActivityThread.access$900(ActivityThread.java:147)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)

我的项目由两个模块组成, test-ktapp , 分别用于新的 Kotlin 内容和现有的 Java 代码。 test-kt/build.gradle具有以下内容:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.kotlin.srcDirs += 'src/main/kotlin'
main.java.srcDirs += 'src/main/kotlin'
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
}

buildscript {
ext.kotlin_version = '0.11.91.2'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.android.tools.build:gradle:1.1.0'
}
}

repositories {
mavenCentral()
}

我尝试在 app 中添加 Kotlin 库作为依赖项。也没有运气。有什么我想念的吗?

编辑:经过进一步调查,这似乎只在我使用属性引用(例如 ::x )时发生,而不是在我使用扩展方法时发生。我肯定包含了 kotlin-reflect ... 有任何想法吗?

最佳答案

我在升级到 Kotlin 版本 0.11.91.2 时也遇到了这个问题。显然存在一个问题,即 Android 工具集没有将带有点的文件打包到资源中。 (请注意,异常引用的文件 .kotlin_string_table 前面带有一个点)。

A fix已经写好但还没有发布。您可以尝试使用 Kotlin 的快照版本以利用它,或者等待下一次更新。

关于android - Kotlin IllegalStateException : Resource not found in classpath: kotlin/. kotlin_string_table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29830715/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com