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 ...
随机推荐
- eclipse安装插件的方式 三种:links、eclipse中使用插件安装向导安装、直接copy插件到对应的eclipse目录 MyEclipse10安装SVN插件
myeclipse安装插件 1.直接将插件copy到myeclipse目录下的dropins目录下(没有目录就新建一个),重启,详细参考 MyEclipse使用总结——MyEclipse10安装SVN ...
- VMware workstation 与 VMware GSX Server 的区别
http://xsagaplus.iteye.com/blog/358917VMware是提供一套虚拟机解决方案的软件,主要产品分为如下三个. VMware-ESX-Server 这个版本并不需要操 ...
- IntelliJ IDEA 14 拉取SVN maven 多模块项目 部署tomcat 详细图解!
二话不说 进入主题 我们创建空项目实际上是项目空间 进入主界面 想用svn必须先启用它 选择Subversion 拉取 svn项目 你会发现这里检测不到目录 我们进入 File>Seting 里 ...
- 通俗易懂,C#如何安全、高效地玩转任何种类的内存之Span的脾气秉性(二)。 异步委托 微信小程序支付证书及SSL证书使用 SqlServer无备份下误删数据恢复 把list集合的内容写入到Xml中,通过XmlDocument方式写入Xml文件中 通过XDocument方式把List写入Xml文件
通俗易懂,C#如何安全.高效地玩转任何种类的内存之Span的脾气秉性(二). 前言 读完上篇<通俗易懂,C#如何安全.高效地玩转任何种类的内存之Span的本质(一).>,相信大家对sp ...
- Linux vm运行参数 - overcommit相关的参数
一.前言 终于可以进入Linux kernel内存管理的世界了,但是从哪里入手是一个问题,当面对一个复杂系统的时候,有时候不知道怎么开始.遵守“一切以人为本”的原则,我最终选择先从从userspace ...
- java concurrent之ReentrantLock
在编码的过程中.有时候我们不得不借助锁同步来保证线程安全.synchronizedkeyword在上一篇博客中已经介绍.自从JDK5開始,加入了还有一种锁机制:ReentrantLock. 二者的差别 ...
- Android笔记(十)ListView
ListView是Android中最经常使用的控件之中的一个,也是最难用的控件. ListView的作用是展示大量的数据,只是ListView并非直接和数据打交道.而是通过适配器作为中间桥梁. 1.首 ...
- Python find() 方法
描述 Python find() 方法从字符串中找出某个子字符串第一个匹配项的索引位置,该方法与index() 方法一样,只不过如果子字符串不在字符串中不会报异常,而是返回-1. 语法 find() ...
- 用jQuery.ajaxWebService请求WebMethod,Ajax处理实现局部刷新;及Jquery传参数,并跳转页面 用post传过长参数
首先在aspx.cs文件里建一个公开的静态方法,然后加上WebMethod属性. 如: [WebMethod] public static string GetUserName() { //. ...
- windows live writer 2012 0x80070643
折腾了两天,windows live writer 安装不成功,最后放弃了,发现一个叫做菊子曰的软件,但是免费版本的,发图片有限制,感觉非常不爽.windows live writer报错如下 ...