Deep
Deep

Reputation: 703

Android : Program type already present: com.google.common.base.FinalizableReferencequeue

Getting the following error during my gradle build :

Program type already present: com.google.common.base.FinalizableReferencequeue

I understand there to be some solutions on the site for similar such errors. But they don't work for me + they don't help me search the root cause of the error. Can someone please help with some pointers ??

App level gradle file:

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')
}

Upvotes: 1

Views: 1382

Answers (1)

xiaomi
xiaomi

Reputation: 6713

The root cause is that 2 libraries are using the same dependencies.

This often occurs when a library embedded another library (such as a fat jar) but you also declare it as a dependency (i.e. via the word compile)

In your case, you have 2 (or more) libraries using com.google.common.base.FinalizableReferencequeue which, after a short googling, correspond to Guava, and is one of your dependencies.

An easy solution would be to remove the line compile 'com.google.guava:guava:19.0'.

But if you want to know how to fix your problem, you can run the dependencies task for your app. Here app refers to the name of the module under the project.

// run gradlew which is on your root project.

// linux / osx
./gradlew app:dependencies

// windows
gradlew app:dependencies

This will print all the configuration and its dependencies. To narrow down, you can focus on only one build by adding for example --configuration debugCompileClasspath or with a flavor named myFlavor --configuration myFlavorDebugCompileClasspath (case sensitive).

You should now be able to see which other libraries is using guava and exclude it like :

compile(<dependency_path>) { //works also with project(<proj_name>)
    exclude group: "com.google.guava", module: "guava" 
}

(see more about exclude)

Upvotes: 3

Related Questions