gpt4 book ai didi

java - 如何解决android studio中构建gradle中的重复条目

转载 作者:行者123 更新时间:2023-11-29 08:32:39 24 4
gpt4 key购买 nike

我正在尝试将 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
}

}

最佳答案

java.util.zip.ZipException: duplicate entry: android/support/v4/database/DatabaseUtilsCompat.class

问题

  • 排除模块:'support-v4'

不要

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

关于java - 如何解决android studio中构建gradle中的重复条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46665696/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com