Android工作室 - 制作新应用

时间:2015-01-05 15:43:56

标签: android

我试图在Android Studio中创建一个应用程序。我点击构建>生成签名的apk然后选择目标并完成。它抛出了我的代码:

错误:任务':app:dexRelease'执行失败。

  

com.android.ide.common.internal.LoggedErrorException:无法运行命令:       C:\ Users \ username \ AppData \ Local \ Android \ sdk \ build-tools \ 21.1.2 \ dx.bat --dex --output C:\ Users \ username \ AndroidstudioProjects \ Myproject \ app \ build \ intermediates \ dex \ release --input-list = C:\ Users \ username \ AndroidstudioProjects \ Myproject \ app \ build \ intermediates \ tmp \ dex \ release \ inputList.txt   错误代码:       2   输出:       意外的顶级例外情况:       com.android.dex.DexException:多个dex文件定义了Landroid / support / v4 / view / PagerAdapter;           在com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)           在com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)           在com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)           在com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)           在com.android.dx.merge.DexMerger.merge(DexMerger.java:189)           在com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)           在com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)           在com.android.dx.command.dexer.Main.run(Main.java:246)           在com.android.dx.command.dexer.Main.main(Main.java:215)           在com.android.dx.command.Main.main(Main.java:106)

2 个答案:

答案 0 :(得分:0)

删除 libs 文件夹中的android-support-v4.jar

答案 1 :(得分:0)

将此行添加到您的顶级gradle文件

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
}