I ported an Eclipse project to Android Studio IDE, the project was using android-support-v4, android-support-v13 and appcompat_v7 libraries, everything was fine but when I used Android Studio I got the following error each time I tried to run the project:

我将一个Eclipse项目移植到Android Studio IDE,项目使用了Android -support-v4、Android -support-v13和appcompat_v7库,一切都很好,但是当我使用Android Studio时,每次我尝试运行这个项目时,都会遇到以下错误:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v13/app/FragmentCompatICS;
    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:454)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:302)
    at com.android.dx.command.dexer.Main.run(Main.java:245)
    at com.android.dx.command.dexer.Main.main(Main.java:214)
    at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 2
Information:BUILD FAILED

Note: it works once I cleaned the project, then the same error happened again next run, so I have to clean each time I run.

注意:一旦我对项目进行了清理,就会发生同样的错误,下次运行时,我必须清理一次。

Anyone have any idea why this keep happenning?

谁知道为什么会这样吗?

1 个解决方案

#1


0

First please refer to this answer in figuring out why it occurs and fixing it as it suggests.

首先,请参考这个答案,找出它发生的原因,并按照它的建议去修复它。

And in case anyone finds out that that answer could not be applied to android library project, here is the snippet to fix

如果有人发现这个答案不能应用到android的库项目中,那么下面的代码片段就可以解决了。

compile (project(':yourAndroidLibrary')){ exclude module: 'support-v13' }

编译(项目(':yourAndroidLibrary')){排除模块:'support-v13'}


You will find problems

你会发现问题

Unsupported Gradle DSL method found: 'exclude()'

不支持的Gradle DSL方法发现:“排除()”

if you use compile project(':yourAndroidLibrary'){ exclude module: 'support-v13' }

如果您使用compile项目(':yourAndroidLibrary'){排除模块:'support-v13'}

The differences are the bracelet "(" and ")" before "project".

不同之处是在“项目”之前的手链“(”和“)”。

更多相关文章

  1. 【Android】策略模式封装百度地图路线规划模块
  2. 将不同的Android项目连接到现有的Google-Endpoints后端
  3. 如何将Maven添加到现有的IntelliJ Android项目中
  4. 我心依旧之Android Camera模块FW/HAL3探学序
  5. Thrift项目Server端开发流程
  6. OSGi 学习之路(4) - osgi的模块化 java在模块化的局限性
  7. [java混淆器问题] 如何让web项目的class文件不能被反编译,又能在w
  8. java socket项目打包成可运行的JAR包!!!!!
  9. 阿里云服务器上部署java项目(安装jdk,tomcat)

随机推荐

  1. Android百度地图之位置定位和附近查找代
  2. [置顶] Android多分辨率和多屏幕的布局适
  3. 安卓软硬结合,热点技术实践总结:《Android
  4. 浅谈android中的图片处理之基本绘图(一)
  5. 谁说Android的动画不廉价(五)之水波纹动画
  6. 【Android】多语言Values
  7. android之spinner背景、字体颜色
  8. Android动态加载jar/dex
  9. Android : 输入设备键值从底层到应用层的
  10. Android之SurfaceView简介(三)