Android Studio:Multiple dex files define Landroid/support/annotation/AnimRes
近期真的比較忙,一不小心博客又荒了两个月。
从今天起。决定重返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的更多相关文章
- Android Studio 运行出现 Multiple dex files define Landroid/support/annotation/AnimRes 解决方法
引入的工程的android-support-v4.jar版本跟自己工程的android-support-v4.jar的版本不一样
- 运行出现 Multiple dex files define Landroid/support/annotation/AnimRes 解决方法
1. 拷贝google-play-services_lib/libs/目录下的android-support-v4.jar到xxxr/libs/下 2. 工程进行如下设置:
- 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 ...
- Android 友盟和微信的包冲突:Multiple dex files define Lcom/tencent/a/a/a/a/a;
最近App中有个需求是添加微信支付,就在微信技术官网 http://open.weixin.qq.com,查看一下文档,然后下载SDk,Demo.把SDK集成进项目. 照着微信的文档,把jar包和进来 ...
- 关于安卓百度地图SDK报错:Multiple dex files define Lcom/baidu/android/bbalbs/common/a/a;
1.找到.jar包 2.右键,用WinRAR打开 3.打开com/baidu/ 4.保留location,其他全删掉 5.这样将不会报错,可以运行了!!!
- eclipse 导入工程报错Unable to execute dex: Multiple dex files define Landroid/annotation/SuppressLint
对策: 检查libs 是否有重复加载的.
- 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 ...
- Multiple dex files define Lcom/google/gson/internal/Streams$AppendableWriter$CurrentWrite;
开发中引入第三方 aar 时编译同过,运行时出现问题: Multiple dex files define Lcom/google/gson/internal/Streams$AppendableWr ...
- Android Studio com.android.dex.DexException: Multiple dex files define(重复引用包),androiddefine
Android Studio com.android.dex.DexException: Multiple dex files define(重复引用包),androiddefine 如果你用Andr ...
随机推荐
- XML编辑器之XMLSpy2005
http://baike.baidu.com/link?url=79rnCuCnvoYJZHmQUBdc9INRvBTsWO_RYjWXgWI2sP1thb2WV5_6j_ygzInE7bdE7zaC ...
- Sublime Text 2搭建Go开发环境(Windows)
转自:http://blog.csdn.net/love_se/article/details/7754274 下载packcontrol包地址:http://www.imjeff.cn/blog/6 ...
- 【ASP.NET Core】EF Core - “影子属性” 深入浅出经典面试题:从浏览器中输入URL到页面加载发生了什么 - Part 1
[ASP.NET Core]EF Core - “影子属性” 有朋友说老周近来博客更新较慢,确实有些慢,因为有些 bug 要研究,另外就是老周把部分内容转到直播上面,所以写博客的内容减少了一点. ...
- unity 主循环
在unity官方文档中看到这个图,感觉很有用,各事件的先后时机看得较清楚. 连接:http://docs.unity3d.com/Manual/ExecutionOrder.html
- linux的fork()函数具体解释 子进程复制父进程什么
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<unistd.h ...
- Linux安装Qt详细步骤 亲测总结
下载 qt-everywhere-opensource-src-4.8.4.tar.gz================准备工作====================yum install kern ...
- CentOS的字符集locale的设置
LANGLC_*的默认值,是最低级别的设置,如果LC_*没有设置,则使用该值.类似于 LC_ALL. LC_ALL它是一个宏,如果该值设置了,则该值会覆盖所有LC_*的设置值.注意,LANG的值不受该 ...
- 每日英语:Robots To Revolutionize China
A new worker's revolution is rising in China and it doesn't involve humans. With soaring wages and a ...
- mongodump 失败且导致mongo服务挂掉【本质原因,wt文件损坏】
====================================================== 标题遇到的问题是我要解决的问题的中间环节. 原本问题是:需要在之前standlone的Mo ...
- Python 部署 flask 用uwsgi和nginx
安装uwsgi nginx 具体方法请百度 1.在项目目录下建立.ini文件 xad_uwsgi.ini [uwsgi] master=true #项目目录 chdir=/root/zhaoyingj ...