Android工程の方法数は64 kを超え、The number of method references in a.dex file cannot exceed 64K.
1497 ワード
最近、古いEclipseプロジェクトをAndroid Studioに転送した後、gradleでいくつかの依存を追加し、プロジェクトはmakeできますが、runが間違っていると報告しました.
の原因となる
アイテムのメソッド数が64 kを超えているので、下請け処理が必要!
Android Studioソリューション:
Eclipseの解決方法については、対応するプラグインが必要らしい!
最初のステップ、依存関係の追加
ステップ2、構成を追加します.build.gradle(app) buildTypes
ここでは defaultConfigで を追加
ステップ3では、MultiDexApplicationの作成カスタムアプリケーションカスタムアプリケーションがある場合は、 を書き換えます.自分のプロジェクトにカスタムアプリケーションがない場合、カスタムも必要ない場合は、
最後に
これ、敬礼!
Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
の原因となる
アイテムのメソッド数が64 kを超えているので、下請け処理が必要!
Android Studioソリューション:
Eclipseの解決方法については、対応するプラグインが必要らしい!
最初のステップ、依存関係の追加
implementation 'com.android.support:multidex:1.0.1'`
ステップ2、構成を追加します.build.gradle(app)
dexOptions {
preDexLibraries false
}
ここでは
buildTypes
に追加する必要があります.appが他のmoduleに依存している場合は、対応するmoudle(build.gradle)にも追加する必要があります.multiDexEnabled true
ステップ3では、MultiDexApplicationの作成
android.support.multidex.MultiDexApplication;
を継承し、attachBaseContext
メソッド/**
* 64K,
* fjj 2019-3-27
* @param base
*/
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this); //
}
AndroidManifest.xml
のapplication
の下で直接指定できます:android:name="android.support.multidex.MultiDexApplication;"
最後に
これ、敬礼!