LoginSignup
11
12

More than 5 years have passed since last update.

Android開発してたらNoClassDefFoundErrorでハマった

Posted at

Android開発しててクラッシュレポートを入れようとTwitterのCrashAnalyticsをいれたらjava.lang.NoClassDefFoundErrorでロリポップ以降は問題なかったが、Andorid4.x落ちてはまったのでその時の解決メモ

原因

apkに含められるメソッドの総数は65,535が上限にひかかった

ちなみにLolipop以降は65k問題対策されてて問題ないらしい。

解決方法

gradle側の変更

    defaultConfig {
        applicationId "xx.xx.xxx"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0.00"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true <-- ここ追加
       
       
       
    dependencies {
        compile 'com.android.support:multidex:1.0.0'
    }

Applicationクラス

ApplicationクラスにMultiDexApplicationを継承させる

たぶんこれでOK

11
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
12