Multidex安装失败 [英] Multidex installation failure
问题描述
我正在使用CircledImageView库。它适用于棒棒糖+ Android版本。但在kitkat它崩溃了。所以在谷歌搜索后。我发现我必须在我的应用程序中实现multidex。
I'm using CircledImageView library. It works fine on lollipop+ android versions. But in kitkat it's crashing. So after searching on google. I found that i have to implement multidex in my app.
所以这是我的应用程序类。
So this my application class.
public class FireApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Firebase.setAndroidContext(this);
Fresco.initialize (this);
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
在defaultconfig下的build.gradle中,MultiDexEnabled为true
And in build.gradle under defaultconfig MultiDexEnabled is true
multiDexEnabled true
但是当我运行应用程序时,我收到以下错误。
But when I run the app, I get the following error.
java.lang.NoSuchFieldException: Field dexElementsSuppressedExceptions not found in class dalvik.system.PathClassLoader
at android.support.multidex.MultiDex.findField(MultiDex.java:288)
at android.support.multidex.MultiDex.access$300(MultiDex.java:57)
at android.support.multidex.MultiDex$V19.install(MultiDex.java:390)
at android.support.multidex.MultiDex$V19.access$000(MultiDex.java:369)
at android.support.multidex.MultiDex.installSecondaryDexes(MultiDex.java:242)
at android.support.multidex.MultiDex.install(MultiDex.java:161)
at android.support.multidex.MultiDexApplication.attachBaseContext(MultiDexApplication.java:39)
at com.buckydroid.anonchat.FireApp.attachBaseContext(Unknown Source)
at android.app.Application.attach(Application.java:182)
at android.app.Instrumentation.newApplication(Instrumentation.java:991)
at android.app.Instrumentation.newApplication(Instrumentation.java:975)
at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4564)
at android.app.ActivityThread.access$1500(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5268)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
推荐答案
检查以下步骤此步骤
1)在build.gradle文件中添加依赖项:
1) Add dependency in your build.gradle file :
compile 'com.android.support:multidex:1.0.0'
2)启用multidex并设置堆大小
2) Enable multidex and set heap size
defaultConfig {
applicationId "your package name"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
3)在Application类中添加此
3) In Application class add this
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
4)在你的清单中的<中添加它应用>
标签:
4) Add this in your manifest in <application>
tag :
android:name=".YourApplicationClassName"
这篇关于Multidex安装失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!