[英]Android/Kotlin Crash on Start 4.1.2 - ExceptionInInitializerError
I'm using Kotlin
within my app; 我在应用程序中使用Kotlin
; however, when testing on lower API devices, it crashes on start. 但是,在较低API设备上进行测试时,启动时会崩溃。
Even attaching a debugger to the onCreate
for the Splash Activity
, it still crashes before any breakpoint. 即使将调试器附加到Splash Activity
的onCreate
,它也仍然在任何断点之前崩溃。
I was able to get a callstack once, but I can't get any other callstacks. 我一次只能获得一个调用堆栈,但无法获得其他任何调用堆栈。
Caused by: java.lang.NoClassDefFoundError: kotlin.jvm.internal.Intrinsics
╔════════════════════════════════════════════════════════════════════════════════════════
║ Thread: main
╟────────────────────────────────────���───────────────────────────────────────────────────
║ AppCompatDelegateImplBase$1.uncaughtException (AppCompatDelegateImplBase.java:66)
║ App$1.uncaughtException (App.java:59)
╟────────────────────────────────────────────────────────────────────────────────────────
║ java.lang.ExceptionInInitializerError
║ at com.my_company.app.ui.shared.BaseActivity.onStart(BaseActivity.kt:164)
║ at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
║ at android.app.Activity.performStart(Activity.java:5018)
║ at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
║ at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
║ at android.app.ActivityThread.access$600(ActivityThread.java:130)
║ at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
║ at android.os.Handler.dispatchMessage(Handler.java:99)
║ at android.os.Looper.loop(Looper.java:137)
║ at android.app.ActivityThread.main(ActivityThread.java:4745)
║ at java.lang.reflect.Method.invokeNative(Native Method)
║ at java.lang.reflect.Method.invoke(Method.java:511)
║ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
║ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
║ at dalvik.system.NativeStart.main(Native Method)
║ Caused by: java.lang.NoClassDefFoundError: kotlin.jvm.internal.Intrinsics
║ at com.my_company.app.notification.NotificationType.<init>(NotificationType.kt)
║ at com.my_company.app.notification.NotificationType.<clinit>(NotificationType.kt:10)
║ ... 15 more
╚════════════════════════════════════════════════════════════════════════════════════════
Which points at: val intentFilter = IntentFilter(NotificationType.INVITE_RECEIVED)
哪个指向: val intentFilter = IntentFilter(NotificationType.INVITE_RECEIVED)
which is an extension function that allows me pass my NotificationType enum into the IntentFilter. 这是一个扩展功能,允许我将NotificationType枚举传递到IntentFilter中。
enum class NotificationType(private val str: String) {
// Orders
ORDER_HOST_PAID("ORDER_HOST_PAID"),
...
}
I don't know what would cause this issue, as I use Kotlin
in another app without this issue. 我不知道什么会导致此问题,因为我在没有该问题的另一个应用程序中使用了Kotlin
。 Could it a gradle issue? 可以解决问题吗?
I'm using ext.kotlin_version = '1.2.0-beta-88'
我正在使用ext.kotlin_version = '1.2.0-beta-88'
It was because while I had multiDexEnabled true
, I was not extending MultiDexApplication
. 这是因为当我将multiDexEnabled true
,我没有扩展MultiDexApplication
。 That is only required if you're supporting API 20 or lower. 仅在支持API 20或更低版本时才需要。
Adding the library to your dependencies. 将库添加到您的依赖项。
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 26
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
And extending MultiDexApplication
: 并扩展MultiDexApplication
:
public class MyApplication extends MultiDexApplication
Answer: https://stackoverflow.com/a/39831657/3106174 答案: https : //stackoverflow.com/a/39831657/3106174
I had the same error and I solved it with MultiDex, like described on this link : https://developer.android.com/studio/build/multidex.html 我遇到了相同的错误,并使用MultiDex解决了该错误,如此链接中所述: https : //developer.android.com/studio/build/multidex.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.