导入安卓项目到 adt-bundle 遇到的坑Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files

背景:由于特殊情况,不得不用adt-bundle导入了新的安卓项目,导入最初是有错误的,在一顿操作猛如虎的配置下

(其中有SDK版本的选择,注意SDK的引用路径和环境变量配置。

有Project->Properties->Android->Project Build Target 的勾选 和 Java Compiler的JDK编译level的选择。

有Window->Preferences->Android 下的SDK Location 要为你的SDK路径。

有 Build Path 的配置。

有AndroidManifest.xml 下 android:targetSdkVersion属性的值等等 )

如果你幸运的话以上就能解决问题了

如果不是那么幸运,在解决IDE的自动检索报的错误之后,此时你的项目已经没有红色叹号和红叉等情况了。

但是在编译运行的时候 可能会出现以下报错

[2019-11-21 14:39:47 - LocateDeployment_V1.2.0] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$2) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class.

Unable to execute dex: Multiple dex files define Lorg/apache/commons/codec/Decoder;

Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/apache/commons/codec/Decoder;

以上,后面路径大都不一样,但大概率可能都是因为引用的 jar包有冲突,重复了

以上报错为例,在IDE的Search面板下 Search->Java Search  搜索错误路径下的一个关键字,如 codec,Search For 选择Pachage,Limit To选择 All occurrences,如下

收索结果如下,观察一下是不是在不同jar包下有一些相同的包呢,我的重复的包在Android Private Libraries 下的某个 jar包下

根据后面的路径查找项目中重复的包 ,直接把该包所在的 jar包干掉吧(以防外一可以备份),

如果在IDE的项目下右键删除无效,就到本地目录下删除。

重复包删除之后Refresh ,Clean 重新运行就可以喽

 

最后,还是建议使用 AndroidStudio 开发安卓项目,

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值