Android程序编译时报错:duplicate entry: android/support/v4/content/res/TypedArrayUtils.class
来源:互联网 发布:中国的穆斯林问题 知乎 编辑:程序博客网 时间:2024/05/21 07:52
编写不易,如有转载,请声明出处: 梦回河口:http://blog.csdn.net/zxc514257857/article/details/72633396
为了解决这个报错,弄到晚上快12点,现在怀着激动的心情记录一下解决过程:
报错全部内容如下:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/content/res/TypedArrayUtils.class
报错分析
根据报错信息分析是重复依赖了V4包导致的报错。
因为使用AndroidStudio,我们大部分时候默认使用的是v7包,而V7包默认包含V4包的,一旦我们依赖的第三方如果使用V4包,就有可能导致V4包中文件的冲突。
网上的解决办法如下:
方法一:
项目中和依赖库中都有明显的V4包依赖,删除一个就可以了。也有可能是项目中的Libs文件中既添加了V4的jar包又添加了V4包的依赖。
这两种情况都比较简单,我不会犯这样的错误
方法二:
不删除第三方库中的V4包,直接在主工程Module的build.gradle文件中添加如下:
configurations { all*.exclude group: 'com.android.support', module: 'support-v4'}
这个我也试过,但没有解决我的问题
方法三:
项目中和依赖库中都使用V7包,将依赖库中的V7包换成对应版本的V4包,比如:v7:25.1.0 和v4:25.1.0
我自己实现的方法:
我发现我项目中和依赖库中都依赖的是V7包,而且我删掉依赖库中的V7包后,依赖库中的需要V4包支持的代码会报错,没有使用项目中的V4包,所以依赖库中的V4的依赖不能删掉,我在网上找到了方法三,更换之后还是报错,但我将v4包改为目前最新版本 v4:26.0.0-alpha1 依赖时,问题解决
真神奇的报错!关键是项目已经迭代了7个版本,之前开发了几个月都没有出现这个问题,今天一打开项目就报着个错误,真是抽风了,而且问题解决后现在感觉还是莫名其妙的,现在时间0:06,下班回家!
———-因本人才疏学浅,如博客或Demo中有错误的地方请大家随意指出,与大家一起讨论,共同进步,谢谢!———-
- Android程序编译时报错:duplicate entry: android/support/v4/content/res/TypedArrayUtils.class
- duplicate entry: android/support/annotation/ColorRes.class 打包时报错解答
- android项目build问题 duplicate entry :android/support/v4/widget/ViewDragHelper$callback.class
- duplicate entry: android/support/annotation/ColorRes.class
- 记录java.util.zip.ZipException: duplicate entry: android/support/v4/os/BuildCompat.class
- java.util.zip.ZipException: duplicate entry: android/support/v4/text/TextUtilsCompat.class
- TransformException: java.utiZipException: duplicate entry: android/support/annotation/ColorRes.class
- 【Andoid Studio升级】duplicate entry: android/support/v7/appcompat/R$anim.class
- 【环信升级之坑】duplicate entry: android/support/annotation/ColorRes.class
- java.util.zip.ZipException: duplicate entry: android/support/annotation/ColorRes.class
- Android 使用viewpager时报Didn't find class "android.support.v4.view.Viewpager"错误
- Didn't find class "android.support.v4.content.FileProvider" on path:
- android/support/v4/text/TextUtilsCompat.class异常
- Exception_android_java.util.zip.ZipException: duplicate entry:android/support/multidex/MultiDex
- Unable to get provider android.support.v4.content.FileProvider
- android.content.res.TypedArray
- CheckBox报错Error inflating class android.widget.CheckBox, Caused by: android.content.res.Resources$No
- CheckBox报错Error inflating class android.widget.CheckBox, Caused by: android.content.res.Resources$No
- View的绘制流程分析之三 -- layout
- 计算机网络漫谈之UDP和TCP
- Spanning trees in a secure lock pattern UVALive
- View的绘制流程分析之四 -- draw
- 模板类与类模板、函数模板与模板函数等的区别 (四)
- Android程序编译时报错:duplicate entry: android/support/v4/content/res/TypedArrayUtils.class
- ubuntu下从源码编译比特币(Bitcoin)客户端
- IO流
- python远程调用rpc模块xmlrpclib
- 使用Docker搭建hadoop集群
- Android Studio自用配置
- spring和mybatis的整合简介
- 4833: [Lydsy2017年4月月赛]最小公倍佩尔数
- First集和Follow集,FirstVt集和LastVt集的计算