Program type already present: com.google.thirdpart

2019-07-16 12:16发布

问题:

When I am try to compile my application ,the error shows

Program type already present: com.google.thirdparty.publicsuffix.TrieParser Message{kind=ERROR, text=Program type already present: com.google.thirdparty.publicsuffix.TrieParser, sources=[Unknown source file], tool name=Optional.of(D8)}

Is there any issue in my gradle files?

My project level bulid.gradle is

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {

        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:3.2.1'

       /* classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'*/
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
ext.googlePlayServicesVersion = '11.4.0'
ext.supportLibraryVersion = '27.0.1'
allprojects {

    repositories {
        maven {

            url 'https://maven.google.com/'
            name 'Google'

        }
        jcenter()
        maven { url 'https://www.jitpack.io' }
    }



}
subprojects {

    tasks.withType(Javadoc).all { enabled = false }
}
task clean(type: Delete) {

    delete rootProject.buildDir
}

app level build.gradle is

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        maven { url 'https://maven.google.com' }
    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1.25.4'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'


repositories {
    maven {

        url 'https://maven.fabric.io/public'
    }
    /*maven {

        url 'http://sdk.uxcam.com/android/' //commented can be used later
    }*/
}
/*
apply plugin: 'com.neenbedankt.android-apt'
*/
android {
    lintOptions {

        disable "ResourceType"
    }
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath false
            }
        }
        applicationId 'com.wedviser.matrimony'
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 31
        versionName "2.0.1"
        vectorDrawables.useSupportLibrary = true
        //testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        // Enabling multidex support.
        multiDexEnabled true
        manifestPlaceholders = [HOCKEYAPP_APP_ID: "cbb545807562491aaafac6118c9116a6"]
    }
    buildTypes {
        release {

            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {

        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/ECLIPSE_.SF'
        exclude 'META-INF/ECLIPSE_.RSA'
    }
    flavorDimensions 'default'
    productFlavors {

        development {
            dimension 'default'
            minSdkVersion 19
            applicationId 'com.wedviser.matrimony.dev'
            targetSdkVersion 27
            versionCode 56
            versionName '1'
        }
        production {
            dimension 'default'
            minSdkVersion 19
            applicationId 'com.wedviser.matrimony'
            targetSdkVersion 27
            versionCode 57
            versionName '2.1.8'
        }
    }
}
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation project(':mobicomkitui')
    implementation('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
        transitive = true;
    }
    // for development only .need to remove for releasing //
    // implementation 'net.hockeyapp.android:HockeySDK:4.1.4'

    implementation files('libs/GoogleConversionTrackingSdk-2.2.4.jar')
    implementation 'com.google.firebase:firebase-messaging:15.0.2'
    implementation 'de.hdodenhof:circleimageview:2.1.0'

    // Account Kit
    //implementation 'com.uxcam:uxcam:2.5.9@aar' // commented can be used later
    implementation 'com.google.android.gms:play-services-analytics:15.0.2'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'io.github.luizgrp.sectionedrecyclerviewadapter:sectionedrecyclerviewadapter:1.0.4'
    implementation 'com.github.bumptech.glide:glide:4.5.0'
    implementation 'com.opalox.rangebarvertical:rangebarvertical:1.1'
    implementation 'me.itangqi.waveloadingview:library:0.3.2'
    implementation 'com.android.support:customtabs:27.1.1'
    implementation 'com.jakewharton:butterknife:8.6.0'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.facebook.android:facebook-android-sdk:4.27.0'
    implementation 'com.squareup.okhttp3:okhttp:3.7.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.squareup.retrofit2:retrofit:2.0.2'
    implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
    implementation 'com.github.Raizlabs.DBFlow:dbflow-core:4.0.0-beta5'
    implementation 'com.github.Raizlabs.DBFlow:dbflow:4.0.0-beta5'
    implementation 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0'
    implementation 'com.mcxiaoke.viewpagerindicator:library:2.4.1@aar'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
    implementation 'com.google.android.gms:play-services-vision:15.0.2'
    implementation 'com.crystal:crystalrangeseekbar:1.1.3'
    implementation 'net.danlew:android.joda:2.9.9'
    implementation 'com.github.aryarohit07:picasso-facedetection-transformation:0.3.0'
    implementation 'com.tuyenmonkey:mkloader:1.2.0'
    implementation 'org.parceler:parceler-api:1.1.9'
   /* implementation 'com.google.android.gms:play-services-gcm:15.0.1'*/
    implementation 'com.github.toanvc:floatingactionmenu:0.8.9'
    implementation 'com.github.drawers:SpinnerDatePicker:1.0.4'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:exifinterface:27.1.1'
    api 'com.github.Raizlabs.DBFlow:dbflow-processor:4.0.0-beta5'
    api 'org.parceler:parceler:1.1.9'
    implementation files('libs/GoogleConversionTrackingSdk-2.2.4.jar')
}
apply plugin: 'com.google.gms.google-services'

Also I have used applozic chat platform. And the mobicomkitui build.gradle is

apply plugin: 'com.android.library'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    defaultConfig {

        minSdkVersion 14
        targetSdkVersion 27
        versionCode 1
        versionName "5.8.5"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {

        abortOnError false

    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    api 'com.google.code.gson:gson:2.8.0'
    api 'com.google.firebase:firebase-messaging:15.0.2'
    api 'com.google.android.gms:play-services-maps:15.0.1'
    api 'com.google.android.gms:play-services-location:15.0.1'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    api 'com.android.support:design:27.1.1'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
    implementation 'com.github.bumptech.glide:glide:4.5.0'
    implementation 'com.android.support:cardview-v7:27.1.1'
    api project(':mobicomkit')//Note: use this for customization
    implementation 'com.jakewharton:butterknife:8.6.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    //api 'com.applozic.communication.message:mobicomkit:5.8.5' //Note: use this in case customization is not required

}

/* ext {
    // Where you will see your artifact in Bintray's web interface
    // The "bintrayName" should match the name of the Bintray repro.
    bintrayRepo = 'maven'
    bintrayName = 'applozic-communication-uiwidget'

    // Maven metadata
    publishedGroupId = 'com.applozic.communication.uiwidget'
    libraryName = 'mobicomkitui'
    // Save yourself a head ache, and set this equal to the name of the Android Studio library
    // module. The artifact name needs to match the name of the library.
    artifact = 'mobicomkitui'

    libraryDescription = 'Applozic Communication UI Widget'
    libraryVersion = '5.8.5'

    developerId = 'devashish'
    developerName = 'Applozic'
    developerEmail = 'devashish.mamgain@gmail.com'
}



apply from: 'https://raw.githubusercontent.com/attwellBrian/JCenter/master/installv1.gradle'

apply plugin: 'com.jfrog.bintray'

version = libraryVersion

task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

task javadoc(type: Javadoc) {
    failOnError false // add this line

    source = android.sourceSets.main.java.srcDirs
    //source = android.sourceSets.main.allJava
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives javadocJar
    archives sourcesJar
}

// Bintray
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

bintray {
    user = properties.getProperty("bintray.user")
    key = properties.getProperty("bintray.apikey")

    configurations = ['archives']
    pkg {
        repo = bintrayRepo
        name = bintrayName
        desc = libraryDescription
        publish = true
        publicDownloadNumbers = true
        version {
            desc = libraryDescription
            // Optional. The passphrase for GPG signing'
            // gpg {
            //    sign = true //Determines whether to GPG sign the files. The default is false
            //    passphrase = properties.getProperty("bintray.gpg.password")
            //}
        }
    }
}*/

回答1:

Maybe late, but i found an Answer so there it is :

com.google.thirdparty.publicsuffix.TrieParser is part of Guava, and so it may be included in multiple libraries. In this case, there is at least org.parceler which include guava.

To fix this compilation problem, you have to change the way you import org.parceler, and include it like this :

implementation "org.parceler:parceler-api:1.1.12"
compileOnly  "org.parceler:parceler:1.1.12"
annotationProcessor "org.parceler:parceler:1.1.12"

Source : https://github.com/johncarl81/parceler/issues/182