无法构建android - 多个dex文件

时间:2016-08-08 13:11:07

标签: android cordova phonegap-build

我正在尝试使用Adobe PhoneGap为我的应用构建APK,但我收到了错误消息。 我尝试过我的应用程序的旧版本,以前APK构建成功,但我现在得到同样的错误。

我会感激任何帮助。 这是我在日志中找到的:

Running dex in-process requires build tools 23.0.2.
For faster builds update this project to use the latest build tools.
Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
:transformClassesWithDexForRelease FAILED
FAILURE: Build failed with an exception.

1 个答案:

答案 0 :(得分:0)

尝试将此添加到您的默认配置,然后使缓存无效并重启您的android studio:

 // Enabling multidex support.
 multiDexEnabled true

如果您正在运行单元测试,则需要在Application类中包含它:

public class YouApplication extends Application {

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

}