2017-11-01 17 views
0

私のアプリ内でKotlinを使用しています。ただし、より低いAPIデバイスでテストすると、起動時にクラッシュします。Android/Kotlin Crash on Start 4.1.2 - ExceptionInInitializerError

スプラッシュActivityonCreateにデバッガを接続しても、ブレークポイントの前にクラッシュします。

コールスタックを一度取得できましたが、他のコールスタックは取得できません。私はIntentFilterに私のNotificationTypeを列挙型を渡すことができます拡張機能である val intentFilter = IntentFilter(NotificationType.INVITE_RECEIVED)

:を指し

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 
╚════════════════════════════════════════════════════════════════════════════════════════ 

enum class NotificationType(private val str: String) { 

    // Orders 
    ORDER_HOST_PAID("ORDER_HOST_PAID"), 
    ... 
} 

私はこの問題なしに、他のアプリでKotlinを使用するように私は、この問題を引き起こすかわかりません。それはgradle問題か?

私はmultiDexEnabled trueを持っている間、私はMultiDexApplicationを延長していなかったので、それがあったext.kotlin_version = '1.2.0-beta-88'

答えて

0

を使用しています。 API 20以下をサポートしている場合にのみ必要です。

依存関係にライブラリを追加しています。

android { 
    defaultConfig { 
     ... 
     minSdkVersion 15 
     targetSdkVersion 26 
     multiDexEnabled true 
    } 
    ... 
} 

dependencies { 
    compile 'com.android.support:multidex:1.0.1' 
} 

そしてMultiDexApplicationを拡張:

public class MyApplication extends MultiDexApplication 

回答:https://stackoverflow.com/a/39831657/3106174

を私は同じエラーを持っていた このリンクを説明したように私は、MultiDexとそれを解決:https://developer.android.com/studio/build/multidex.html