java如何在安卓 studio中解决bulid gradle中的重复条目
我正在尝试将eclipse项目导入安卓 studio。之后,将我的jar文件(即支持jar)添加到build gradle
文件中,无论我在eclipse中使用了什么。在这样做时,会出现以下错误
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.安卓.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: 安卓/support/v4/database/DatabaseUtilsCompat.class
我的构建梯度文件是:
apply plugin: 'com.安卓.application'
configurations {
// all*.exclude group: 'com.安卓.support', module: 'support-v4'
// all*.exclude group: 'com.安卓.support', module: 'support-annotations'
}
安卓 {
compileSdkVersion 25
buildToolsVersion "26.0.0"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.xxx.xxxxx"
minSdkVersion 19
targetSdkVersion 25
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-安卓.txt'), 'proguard-rules.txt'
}
}
aaptOptions {
cruncherEnabled = false
}
}
dependencies {
//compile 'com.安卓.support:appcompat-v7:25.2.0'
compile 'com.google.安卓.gms:play-services:+'
compile files('libs/安卓-query-full.0.26.7.jar')
compile files('libs/commons-httpclient-3.0.1.jar')
compile files('libs/glide-3.6.1.jar')
compile files('libs/httpmime-4.1.3.jar')
compile files('libs/library-1.2.1.jar')
compile files('libs/mp安卓chartlibrary-2-2-4.jar')
compile files('libs/picasso-2.4.0.jar')
compile files('libs/安卓-support-v4.jar')
compile files('libs/安卓-support-v7-appcompat.jar')
compile('org.eclipse.paho:org.eclipse.paho.安卓.service:1.0.2') {
exclude module: 'support-v4' // exclude duplicate library
}
}
# 1 楼答案
将下面的代码放在
buildTypes
下面,然后再次重建项目# 2 楼答案
问题
exclude module: 'support-v4'
不要
你应该使用
如果出现问题,那么将其添加到
build.gradle
部分然后
Clean-Rebuild-Run
# 3 楼答案
拆下电话线
加上这一行
也可以在android{}中添加这个
有关更多信息,请查看此链接 https://www.eclipse.org/paho/clients/android/