我在编译一个正在处理的项目时遇到了一些问题。我得到的警告是“(重复的zip条目[guava-18.0.jar:com / google / common / base / Ascii.class])”。
问题出在项目本身上...使用2个AAR形式的外部库。第一个库中阻止了guava-18.0.jar。
第二个库具有与guava-18不同版本的相同类(可能是它们的旧版本),该类从该库复制到classes.jar中。他们基本上将源文件复制到了项目中。
需要说该项目必须同时使用这两个库,我们无法从这两个库中获得另一个版本。因此,如何使它们协同工作……我认为由于API可能已发生更改,所以他们俩都必须使用其版本的guava类。
我尝试使用
{
exclude(group: 'com.google.guava')
}
在构建库的过程中没有成功。
非常感谢您的帮助。
L.E。 -构建文件
apply plugin: 'com.android.application'
//apply plugin: 'dexguard'
apply from: '../gradle_scripts/sdktools.gradle'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 27
buildToolsVersion project.getHighestAvailableTools("27.0.0")
defaultConfig {
applicationId "com.xyzmo.sdkdemo"
minSdkVersion 17
targetSdkVersion 27
multiDexEnabled true
}
buildTypes {
defaultConfig {
versionCode 1
versionName "0.0"
}
/*
// DexGuard Settings
debug {
proguardFiles getDefaultDexGuardFile('dexguard-debug-shrink.pro'), 'dexguard-project.txt'
dependencies
{
}
}
release {
proguardFiles getDefaultDexGuardFile('dexguard-release.pro'), 'dexguard-project.txt'
dependencies
{
}
}
/* */
// Proguard Settings
debug {
debuggable true
minifyEnabled true
//proguardFiles getDefaultProguardFile('proguard-android.txt'), '../proguard_dexguard_configs/proguard-project.txt'
proguardFiles '../proguard_dexguard_configs/proguard-android.txt', '../proguard_dexguard_configs/proguard-project.txt'
buildConfigField "String", "LOGGER_TYPE", "\"CONSOLE_DISK\""
matchingFallbacks = ['release']
dependencies
{
}
}
release {
minifyEnabled true
shrinkResources true
//proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), '../proguard_dexguard_configs/proguard-project.txt'
proguardFiles '../proguard_dexguard_configs/proguard-android.txt', '../proguard_dexguard_configs/proguard-project.txt'
dependencies
{
}
}
/* */
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
ext.android_support_libs_version = "27.1.1"
ext.qr_libs_version = "3.3.0"
ext.lockpattern_version = "10.0.0"
ext.jdom_version = "2.0.6"
ext.jaxen_version = "1.1.6"
ext.spongy_version = "1.54.0.0"
ext.openiab_version = "0.9.8.7"
ext.metadataextractor_version = "2.9.1"
ext.jcifs_version = "1.3.18-kohsuke-1"
ext.commonslang_version = "3.5"
ext.aboutlibraries_libs_version = "5.9.3"
repositories {
flatDir {
dirs "../app/libs"
}
}
dependencies {
api 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
api 'com.android.support:multidex:1.0.2'
api (name:'SIGNificant4AndroidSDK', ext:'aar')
api "haibison.android:lockpattern:$lockpattern_version"
api "com.android.support:support-annotations:$android_support_libs_version"
api "com.android.support:support-compat:$android_support_libs_version"
api "com.android.support:support-core-utils:$android_support_libs_version"
api "com.android.support:support-core-ui:$android_support_libs_version"
api "com.android.support:support-media-compat:$android_support_libs_version"
api "com.android.support:support-fragment:$android_support_libs_version"
api "com.android.support:appcompat-v7:$android_support_libs_version"
api "com.android.support:gridlayout-v7:$android_support_libs_version"
api "com.android.support:recyclerview-v7:$android_support_libs_version"
api "com.android.support:cardview-v7:$android_support_libs_version"
api (name:'Sources_Custom_Support_Library_v4', ext:'aar')
api (name:'SIGNificant4AndroidSDK_JniBitmapOperationsLibrary', ext:'aar')
api (name:'SIGNificant4AndroidSDK_QRCodeScanner', ext:'aar')
api ("com.google.zxing:core:$qr_libs_version")
api ("com.google.zxing:android-core:$qr_libs_version")
api ("com.google.zxing:android-integration:$qr_libs_version")
api ("org.jdom:jdom2:$jdom_version") {transitive = true;}
api ("jaxen:jaxen:$jaxen_version") {transitive = true;}
api ("com.madgag.spongycastle:pkix:$spongy_version") {transitive = true;}
api ("org.onepf:openiab:$openiab_version")
api ("com.drewnoakes:metadata-extractor:$metadataextractor_version") {transitive = true;}
api ("org.samba.jcifs:jcifs:$jcifs_version") {transitive = true;}
api("com.mikepenz:aboutlibraries:$aboutlibraries_libs_version") { transitive = true; }
api ("org.apache.commons:commons-lang3:$commonslang_version")
//Skype For Business
compile(name: "SkypeForBusinessNative", ext: 'aar')
compile(name: "SkypeForBusinessPlatform", ext: 'aar') {
exclude group: 'com.google.guava', module: 'guava'
}
compile(name: "SkypeForBusinessInjector", ext: 'aar')
compile(name: "SkypeForBusiness", ext: 'aar')
compile(name: "SkypeForBusinessNativeEnums", ext: 'aar')
compile(name: "SkypeForBusinessTelemetryClient", ext: 'aar')
compile(name: "SkypeForBusinessTelemetryService", ext: 'aar')
compile(name: "android-database-sqlcipher", ext: 'aar')
///////////////////////////////////////////////////////////
}
答案 0 :(得分:0)
您必须像上面这样更改代码:
compile ('your lib'){
exclude group:'com.google.guava'
}
答案 1 :(得分:0)
尝试在指定exclude group
的情况下使用module
:
implementation("group.id:artifact:version", {
exclude group: 'com.google.guava', module: 'guava'
})
(或compile
,而不是implementation
,如果您使用的是较早的gradle插件)