我正在尝试将eclipse项目导入android studio。之后将我的jar文件,即支持jar添加到build gradle
文件中,无论我在eclipse中使用过什么。这样做会导致错误。
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/database/DatabaseUtilsCompat.class
我的构建gradle文件是:
apply plugin: 'com.android.application'
configurations {
// all*.exclude group: 'com.android.support', module: 'support-v4'
// all*.exclude group: 'com.android.support', module: 'support-annotations'
}
android {
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-android.txt'), 'proguard-rules.txt'
}
}
aaptOptions {
cruncherEnabled = false
}
}
dependencies {
//compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.google.android.gms:play-services:+'
compile files('libs/android-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/mpandroidchartlibrary-2-2-4.jar')
compile files('libs/picasso-2.4.0.jar')
compile files('libs/android-support-v4.jar')
compile files('libs/android-support-v7-appcompat.jar')
compile('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') {
exclude module: 'support-v4' // exclude duplicate library
}
}
答案 0 :(得分:4)
java.util.zip.ZipException:重复条目: 机器人/支撑/ V4 /数据库/ DatabaseUtilsCompat.class
问题
exclude module: 'support-v4'
强> <强>唐&#39;吨强>
compile('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') {
exclude module: 'support-v4' // exclude duplicate library
}
您应该使用
compile group: 'org.eclipse.paho', name: 'org.eclipse.paho.android.service', version: '1.0.2'
如果出现问题,请在build.gradle
部分
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
然后 Clean-Rebuild-Run
。
答案 1 :(得分:0)
将以下代码放在buildTypes
下方,然后重建再次投放项目
packagingOptions {
exclude 'META-INF/NOTICE' // will not include NOTICE file
exclude 'META-INF/LICENSE' // will not include LICENSE file
exclude 'META-INF/DEPENDENCIES' // will not include LICENSE file
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
答案 2 :(得分:0)
删除行
compile files('libs/android-support-v4.jar')
compile files('libs/android-support-v7-appcompat.jar')
compile('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') {
exclude module: 'support-v4' // exclude duplicate library
}
并添加此行
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:support-v4:25.4.0'
compile org.eclipse.paho:org.eclipse.paho.android.service:1.0.2
同时在android {}
中添加此内容repositories {
mavenCentral()
}
有关详细信息,请查看此链接 https://www.eclipse.org/paho/clients/android/