gpt4 book ai didi

java - MultiDex 应用程序 Android

转载 作者:太空宇宙 更新时间:2023-11-03 13:15:58 24 4
gpt4 key购买 nike

今天我遇到了这样的错误:

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

我在我的 build.gradle 中写:

multiDexEnabled true

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

在我的 list 中:

android:name="android.support.multidex.MultiDexApplication"

在我的主要方法中:

public class myMethode extends AppCompatActivity{
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}

但是我收到这些错误:

03-15 12:15:37.066 19676-19676/de.example E/AndroidRuntime: FATAL EXCEPTION: main
03-15 12:15:37.066 19676-19676/de.example E/AndroidRuntime: Process: de.imatics.mediplan, PID: 19676
03-15 12:15:37.066 19676-19676/de.example E/AndroidRuntime: java.lang.RuntimeException: Unable to resume activity {de.imatics.mediplan/de.example.MedicationScheduleActivity}: java.lang.NullPointerException

最佳答案

在android下的build.gradle中exclude meta info like

packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}

还有 MultiDex.install(this); 应该写在 Application 类中,像 Application 类一样扩展

public class MyApp extends Application {

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}

关于java - MultiDex 应用程序 Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36009770/

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