近期真的比較忙,一不小心博客又荒了两个月。

从今天起。决定重返csdn,多多纪录和分享。

先从一个近期被折磨的死去活来的问题。

由于升级了V4包,就一直报这个问题:

com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;

每次都要clean一下,然后才干编译过,光这个过程就浪费了4/5分钟。出现这个问题是由于最新的v4包(compile ‘com.android.support:support-v4:22.2.1’)已经包括了annotation.jar这个包。但其它jar包里也包括这个包造成的。

而非同一时候包括了v4/V7造成的。所以一堆人说在v7包里进行例如以下设置:

compile ('com.android.support:appcompat-v7:22.2.1'){
exclude group: "com.android.support", module: "support-v4"
}

即设置v7包不包括v4,这个设了也是无用的。仅仅要确保用v4和v7 的地方版本号一致就可以。正确的解决方法有例如以下几种:

1。找到项目其它的依赖包,一定在libs里的某个jar包里,隐藏着annotation.jar包,将其删掉就ok了,此为最正统的解决方法;

2,降级v4包。由于高版本号的v4才包括annotation.jar。能够在最外面的build.grable里强制设置:

allprojects {
repositories {
jcenter()
}
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:22.1.0'
}
}

3,在须要v4包的地方exclude掉annotation包。注意compile要多加个括号:

 compile ('com.android.support:support-v4:22.2.1'){
exclude module: 'support-annotations'
}

缺点是每一个用v4包的地方都要这么设置下。

4。在application的build.gradle里的dexOptions设置里添加一句:preDexLibraries = false就ok了:

PS:以上四种方法都能够解决这个问题,推荐正统的方法1和偷懒的方法4。

Android Studio:Multiple dex files define Landroid/support/annotation/AnimRes的更多相关文章

  1. Android Studio 运行出现 Multiple dex files define Landroid/support/annotation/AnimRes 解决方法

    引入的工程的android-support-v4.jar版本跟自己工程的android-support-v4.jar的版本不一样

  2. 运行出现 Multiple dex files define Landroid/support/annotation/AnimRes 解决方法

    1. 拷贝google-play-services_lib/libs/目录下的android-support-v4.jar到xxxr/libs/下 2. 工程进行如下设置:

  3. Android Bug:Error:com.android.dex.DexException: Multiple dex files define Landroid/support/design/widget/CoordinatorLayout$LayoutParams;

    项目编译通过,运行时出现异常: Error:com.android.dex.DexException: Multiple dex files define Landroid/support/desig ...

  4. Android 友盟和微信的包冲突:Multiple dex files define Lcom/tencent/a/a/a/a/a;

    最近App中有个需求是添加微信支付,就在微信技术官网 http://open.weixin.qq.com,查看一下文档,然后下载SDk,Demo.把SDK集成进项目. 照着微信的文档,把jar包和进来 ...

  5. 关于安卓百度地图SDK报错:Multiple dex files define Lcom/baidu/android/bbalbs/common/a/a;

    1.找到.jar包 2.右键,用WinRAR打开 3.打开com/baidu/ 4.保留location,其他全删掉 5.这样将不会报错,可以运行了!!!

  6. eclipse 导入工程报错Unable to execute dex: Multiple dex files define Landroid/annotation/SuppressLint

    对策: 检查libs 是否有重复加载的.

  7. Unable to execute dex: Multiple dex files define异常的解决办法

    问题: [2016-01-06 16:47:58 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/sup ...

  8. Multiple dex files define Lcom/google/gson/internal/Streams$AppendableWriter$CurrentWrite;

    开发中引入第三方 aar 时编译同过,运行时出现问题: Multiple dex files define Lcom/google/gson/internal/Streams$AppendableWr ...

  9. Android Studio com.android.dex.DexException: Multiple dex files define(重复引用包),androiddefine

    Android Studio com.android.dex.DexException: Multiple dex files define(重复引用包),androiddefine 如果你用Andr ...

随机推荐

  1. GFW的前世今生,一部GFW之父方滨兴的发家史

    http://whu.myubbs.com/thread-96390-1-1.html方滨兴(1960年7月17日-),男,中国共chan党党员,中国工程院院士,全国人大代表,中国科学院信息工程研究所 ...

  2. 整理mysql的28个知识点(转)

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/weixin_39220472/article/details/80247011整理mysql28个知 ...

  3. view变化监听器ViewTreeObserver介绍

      A view tree observer is used to register listeners that canbe notified of global changes in the vi ...

  4. Linux内核(16) - 高效学习Linux内核

    世界悲结束了,章鱼哥也退役了,连非诚勿扰中的拜金女也突然的少了很多.这本<Linux内核修炼之道>在卓越.当当.china-pub上也已经开卖了,虽然是严肃文学,但为了保证流畅性,大部分文 ...

  5. Java+Oracle实现事务——JDBC事务

    J2EE支持JDBC事务.JTA事务和容器事务事务,这里说一下怎样实现JDBC事务. JDBC事务是由Connection对象所控制的,它提供了两种事务模式:自己主动提交和手动提交,默认是自己主动提交 ...

  6. nginx实战七

    Nginx优化-配置参数优化上 https://coding.net/u/aminglinux/p/nginx/git/blob/master/optimize/nginx_opt.md Nginx作 ...

  7. Python pow() 函数

    描述 pow() 方法返回 xy(x的y次方) 的值. 语法 以下是 math 模块 pow() 方法的语法: import math math.pow( x, y ) 内置的 pow() 方法 po ...

  8. python AES双向对称加密解密

    高级加密标准(Advanced Encryption Standard,AES),在密码学中又称Rijndael加密法,是美国联邦政府采用的一种区块加密标准.这个标准用来替代原先的DES,已经被多方分 ...

  9. mysql开启skip-name-resolve 导致root@127.0.0.1(localhost)访问引发的ERROR 1045 (28000)错误解决方案

    为什么配置skip-name-resolve? 由于mysql -h${ip} 远程访问速度过慢, mysql -uroot -p123456 根据网友经验(https://www.cnblogs.c ...

  10. Android-Bug:RecyclerView的item不能横向充满的问题

    在使用 RecyclerView 的时候,出现了 item 不能横向充满屏幕的问题, 如下图所示: 解决办法:发现是在使用 Adapter 的时候,在 onCreateViewHolder() 方法的 ...