Dex错误Android Volley库com.android.dex.DexException

时间:2018-06-27 08:29:58

标签: android android-studio android-gradle android-volley android-multidex

由于排球库,我遇到应用程序中的内存问题。他们最近更新了该库,我编译了一个可用的Here。现在,我认为应该解决内存问题。但是现在,当我运行该应用程序时,将会出现一个新错误。

现在我开始收到此错误

Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Caused by: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:72)
at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
... 132 more
Caused by: com.android.dex.DexException: Multiple dex files define Lcom/android/volley/toolbox/ImageLoader$ImageContainer;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
... 134 more

仅当我从android-studio运行该错误时,该错误才会出现,;当我生成签名的apk时,

关于我的项目,我的项目中有两个模块

  • 应用
  • LibraryModule

我正在两个模块中都编译凌空库。

implementation files('libs/volley-1.1.1-rc1.aar')

我的multidex true中已经有defaultConfig{}

我还扩展了 MultidexApplication

public class MyApplication extends MultiDexApplication {

private static MyApplication mInstance;

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

0 个答案:

没有答案