在我的gradle构建过程中出现以下错误:
程序类型已存在:com.google.common.base.FinalizableReferencequeue
我知道网站上有一些类似的错误解决方案。但他们不为我工作+他们不帮我找出错误的根本原因。有人可以请一些指点吗?
应用级gradle文件:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
flavorDimensions "default"
compileSdkVersion 26
//noinspection GradleDependency
buildToolsVersion '26.0.1'
defaultConfig {
versionCode 62
versionName "2.0.62"
applicationId "com.android.embarkation"
minSdkVersion 21
targetSdkVersion 26
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
resValue "string", "releaseDate", "04/25/2018"
ndk {
abiFilters "armeabi-v7a", "x86", "x86_64"
moduleName "recogDoc"
ldLibs = ["android", "log", "jnigraphics"]
}
}
ext {
nativeDebuggable = true
}
def BASE_APP_ID = "com.dxp."
def AIRPORT_APP_ID = "airport"
def VALIDATE_APP_ID = "validate"
def ACI_APP_ID = "aci"
def GANGWAY_APP_ID = "gangway"
def BRAND_NCL = "ncl"
def BRAND_VV = "vv"
def BRAND_DXP = "dxp"
def ENV_INTEG = "Integ_"
def ENV_DEV = "Dev_"
def ENV_QA = "Qa_"
def ENV_SHIFT = "Shift_"
def ENV_SHIFT_QC = "ShiftQC_"
def ENV_DEMO = "Demo_"
def DXP_SUFFIX = "dxp_"
sourceSets {
main.res.srcDirs += 'src/main/res-chat'
main.jniLibs.srcDirs += 'src/main/libs'
}
productFlavors {
devAirport {
setProperty("archivesBaseName", AIRPORT_APP_ID.concat("_").concat(BRAND_VV).concat(ENV_DEV))
def APK_NAME = AIRPORT_APP_ID.concat("_").concat(BRAND_VV).concat(ENV_DEV)
applicationId BASE_APP_ID.concat(AIRPORT_APP_ID)
}
devValidate {
def APK_NAME = VALIDATE_APP_ID.concat("_").concat(BRAND_VV).concat(ENV_DEV)
applicationId BASE_APP_ID.concat(VALIDATE_APP_ID)
}
devAci {
def APK_NAME = ACI_APP_ID.concat("_").concat(BRAND_VV).concat(ENV_DEV)
applicationId BASE_APP_ID.concat(ACI_APP_ID)
}
gangwayDev {
def APK_NAME = GANGWAY_APP_ID.concat("_").concat(BRAND_VV).concat(ENV_DEV)
applicationId BASE_APP_ID.concat(GANGWAY_APP_ID)
}
gangwayQcShip {
def APK_NAME = GANGWAY_APP_ID.concat("_").concat(BRAND_VV).concat(ENV_QA)
applicationId BASE_APP_ID.concat(GANGWAY_APP_ID)
}
qcShipAirport {
def APK_NAME = AIRPORT_APP_ID.concat("_").concat(BRAND_VV).concat(ENV_QA)
applicationId BASE_APP_ID.concat(AIRPORT_APP_ID)
}
qcShipAci {
def APK_NAME = ACI_APP_ID.concat("_").concat(BRAND_VV).concat(ENV_QA)
applicationId BASE_APP_ID.concat(ACI_APP_ID)
}
qcShipValidate {
def APK_NAME = VALIDATE_APP_ID.concat("_").concat(BRAND_VV).concat(ENV_QA)
applicationId BASE_APP_ID.concat(VALIDATE_APP_ID)
}
nclShipGangway {
versionCode 62
versionName "2.1.62"
def APK_NAME = GANGWAY_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_DEV)
applicationId BASE_APP_ID.concat(GANGWAY_APP_ID)
}
nclShipAirport {
versionCode 62
versionName "2.1.62"
def APK_NAME = AIRPORT_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_DEV)
applicationId BASE_APP_ID.concat(AIRPORT_APP_ID)
}
nclShipValidate {
versionCode 62
versionName "2.1.62"
def APK_NAME = VALIDATE_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_DEV)
applicationId BASE_APP_ID.concat(VALIDATE_APP_ID)
}
nclShipAci {
versionCode 62
versionName "2.1.62"
def APK_NAME = ACI_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_DEV)
applicationId BASE_APP_ID.concat(ACI_APP_ID)
}
nclShipQcAirport {
def APK_NAME = AIRPORT_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_INTEG)
applicationId BASE_APP_ID.concat(AIRPORT_APP_ID)
}
nclShipQcValidate {
def APK_NAME = VALIDATE_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_INTEG)
applicationId BASE_APP_ID.concat(VALIDATE_APP_ID)
}
nclShipQcAci {
def APK_NAME = ACI_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_INTEG)
applicationId BASE_APP_ID.concat(ACI_APP_ID)
}
nclShipQcGangway {
def APK_NAME = GANGWAY_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_INTEG)
applicationId BASE_APP_ID.concat(GANGWAY_APP_ID)
}
nclShipQcPremAirport {
def APK_NAME = AIRPORT_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_QA)
applicationId BASE_APP_ID.concat(AIRPORT_APP_ID)
}
nclShipQcPremValidate {
def APK_NAME = VALIDATE_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_QA)
applicationId BASE_APP_ID.concat(VALIDATE_APP_ID)
}
nclShipQcPremAci {
def APK_NAME = ACI_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_QA)
applicationId BASE_APP_ID.concat(ACI_APP_ID)
}
nclShipQcPremGangway {
def APK_NAME = GANGWAY_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_QA)
applicationId BASE_APP_ID.concat(GANGWAY_APP_ID)
}
nclShiftShipAirport {
def APK_NAME = AIRPORT_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_SHIFT)
applicationId BASE_APP_ID.concat(AIRPORT_APP_ID)
}
nclShiftShipValidate {
def APK_NAME = VALIDATE_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_SHIFT)
applicationId BASE_APP_ID.concat(VALIDATE_APP_ID)
}
nclShiftShipAci {
def APK_NAME = ACI_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_SHIFT)
applicationId BASE_APP_ID.concat(ACI_APP_ID)
}
nclShiftShipGangway {
def APK_NAME = GANGWAY_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_SHIFT)
applicationId BASE_APP_ID.concat(GANGWAY_APP_ID)
}
nclShiftQCShipAirport {
def APK_NAME = AIRPORT_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_SHIFT_QC)
applicationId BASE_APP_ID.concat(AIRPORT_APP_ID)
}
nclShiftQCShipValidate {
def APK_NAME = VALIDATE_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_SHIFT_QC)
applicationId BASE_APP_ID.concat(VALIDATE_APP_ID)
}
nclShiftQCShipAci {
def APK_NAME = ACI_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_SHIFT_QC)
applicationId BASE_APP_ID.concat(ACI_APP_ID)
}
nclShiftQCShipGangway {
def APK_NAME = GANGWAY_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_SHIFT_QC)
applicationId BASE_APP_ID.concat(GANGWAY_APP_ID)
}
nclDemoAirport {
def APK_NAME = AIRPORT_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_DEMO)
applicationId BASE_APP_ID.concat(AIRPORT_APP_ID)
}
nclDemoValidate {
def APK_NAME = VALIDATE_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_DEMO)
applicationId BASE_APP_ID.concat(VALIDATE_APP_ID)
}
nclDemoAci {
def APK_NAME = ACI_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_DEMO)
applicationId BASE_APP_ID.concat(ACI_APP_ID)
}
nclDemoGangway {
def APK_NAME = GANGWAY_APP_ID.concat("_").concat(BRAND_NCL).concat(ENV_DEMO)
applicationId BASE_APP_ID.concat(GANGWAY_APP_ID)
}
dxpAirportDemo {
def APK_NAME = AIRPORT_APP_ID.concat("_").concat(BRAND_DXP).concat(ENV_DEMO)
applicationId BASE_APP_ID.concat(AIRPORT_APP_ID)
}
dxpValidateDemo {
def APK_NAME = VALIDATE_APP_ID.concat("_").concat(BRAND_DXP).concat(ENV_DEMO)
applicationId BASE_APP_ID.concat(VALIDATE_APP_ID)
}
dxpAciDemo {
def APK_NAME = ACI_APP_ID.concat("_").concat(BRAND_DXP).concat(ENV_DEMO)
applicationId BASE_APP_ID.concat(ACI_APP_ID)
}
dxpGangwayDemo {
def APK_NAME = GANGWAY_APP_ID.concat("_").concat(BRAND_DXP).concat(ENV_DEMO)
applicationId BASE_APP_ID.concat(GANGWAY_APP_ID)
}
}
signingConfigs {
debug {
storeFile file('keystore/debug.keystore')
}
release {
storeFile file('keystore/release.keystore')
storePassword "DeCurtis@Jaipur2018"
keyAlias "DeCurtis"
keyPassword "DeCurtis@Jaipur2018"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
lintOptions {
// set to true to turn off analysis progress reporting by lint
quiet true
// if true, stop the gradle build if errors are found
abortOnError false
// if true, only report errors
ignoreWarnings true
disable 'MissingTranslation'
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFileName = new File("./../../../../../build/apk/",
"${DXP_SUFFIX}${variant.flavorName}_${versionName}.apk")
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
def couchBaseDependencies = rootProject.ext.couchbaseDependancies
compile fileTree(include: ['*.jar'], dir: 'libs')
// Logging API
compile('com.github.tony19:logback-android-classic:1.1.1-5') {
// workaround issue #73
exclude group: 'com.google.android', module: 'android'
}
// IntegrationTests API
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2') {
// Necessary if your app targets Marshmallow (since Espresso
// hasn't moved to Marshmallow yet)
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile('com.android.support.test:runner:0.3') {
// Necessary if your app targets Marshmallow (since the test runner
// hasn't moved to Marshmallow yet)
exclude group: 'com.android.support', module: 'support-annotations'
}
// compile 'com.decurtis.android.nearbylibrary:nearbylibrary:1.0.1'
compile couchBaseDependencies.couchbaselite
compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
transitive = true;
}
compile project(path: ':cbutil')
compile 'com.decurtis.logger:logger:1.0.3@aar'
compile project(path: ':cbutil')
compile project(':psync2')
compile files('libs/rfidsdk.jar')
compile 'com.android.support:multidex:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:design:26.1.0'
annotationProcessor 'com.jakewharton:butterknife:7.0.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'ru.alexbykov:nopaginate:0.4.3'
compile 'org.springframework.android:spring-android-core:1.0.0.RELEASE'
compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
compile 'uk.co.alt236:bluetooth-le-library-android:1.0.0'
compile 'org.slf4j:slf4j-api:1.7.21'
compile 'com.github.tony19:logback-android-core:1.1.1-5'
compile 'com.android.support:percent:26.1.0'
compile 'com.android.support:support-v13:26.1.0'
compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
compile 'com.google.guava:guava:19.0'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.6.0'
compile 'com.github.gcacace:signature-pad:1.2.0'
compile 'in.srain.cube:ultra-ptr:1.0.11'
annotationProcessor 'io.realm:realm-android:0.82.1'
compile 'io.realm:realm-android:0.82.1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.github.bumptech.glide:glide:4.0.0-RC1'
compile 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.0.2'
compile 'com.github.traex.rippleeffect:library:1.3'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'
compile 'com.jakewharton.timber:timber:4.4.0'
compile 'com.github.ittianyu:BottomNavigationViewEx:1.2.3'
compile 'q.rorbin:badgeview:1.1.0'
compile 'com.jaredrummler:android-device-names:1.0.9'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services-auth:11.0.0'
compile 'com.google.android.gms:play-services-location:11.0.0'
// Retrofit
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
compile 'com.squareup.retrofit2:converter-scalars:2.1.0'
compile 'com.myhexaville:smart-image-picker:1.0'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC1'
compile 'com.decurtis.chatframework:chatframework:1.0.10@aar'
compile 'com.decurtis.logger:logger:1.0.8@aar'
compile project(path: ':cbutil')
compile project(':psync2')
compile 'com.dxp.barcodereader:DXPCameraBarcodeLibrary:1.0.5@aar'
apply plugin: 'com.google.gms.google-services'
compile 'com.decurtis.nearbybeacon:nearbybeacon:1.0.16@aar'
compile 'com.dxp.passportreader:passportreader:1.0.10@aar'
compile 'com.kontaktio:sdk:4.0.0'
compile project(':rules-engine')
compile project(':rules-entities')
compile files('libs/rules.jar')
compile(group: 'com.dxp.mrzreaderlib', name: 'mrzreaderlib', version: '1.0.3', ext: 'aar')
}
答案 0 :(得分:3)
根本原因是2个库使用相同的依赖项。
这通常发生在嵌入另一个库(例如fat jar)的库中,但您也将其声明为依赖项(即通过单词compile
)
在您的情况下,您有两个(或更多)使用com.google.common.base.FinalizableReferencequeue
的库,经过短搜索后,它们对应Guava,并且是您的依赖项之一。
一个简单的解决方案是删除行compile 'com.google.guava:guava:19.0'
。
但是,如果您想知道如何解决问题,可以为您的应用运行依赖项任务。这里app
指的是项目下模块的名称。
// run gradlew which is on your root project.
// linux / osx
./gradlew app:dependencies
// windows
gradlew app:dependencies
这将打印所有配置及其依赖项。要缩小范围,您可以通过添加例如--configuration debugCompileClasspath
或者使用名为myFlavor --configuration myFlavorDebugCompileClasspath
(区分大小写)的风格来仅关注一个构建。
您现在应该能够看到哪些其他库正在使用番石榴并将其排除在外:
compile(<dependency_path>) { //works also with project(<proj_name>)
exclude group: "com.google.guava", module: "guava"
}
(详情请见exclude)