Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle: Error: Program type already present: androidx.activity.R$attr

Tags:

android

gradle

When adding

 implementation 
    ('com.google.android.ads.consent:consent-library:1.0.0') {
        exclude module: 'androidx.activity'
    }

to my app/build.gradle file i get this error: Error: Program type already present: androidx.activity.R$attr

What i did do: 1. gradlew androidDependencies But i cannot find any duplicates

  1. Read: https://developer.android.com/studio/build/dependencies#duplicate_classes.

  2. Other stackoverflow answers suggesting excluding support library versions dont help me

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

configurations {
    all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}

configurations.all {exclude group: 'com.android.support', module: 'support-v13'}

dependencies {
    def nav_version = "1.0.0"

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
    implementation 'androidx.core:core-ktx:1.1.0-alpha05'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'


    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.2-alpha02'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha02'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test:rules:1.1.1'
    androidTestImplementation 'androidx.test:core-ktx:1.1.0'

    implementation "com.vorlonsoft:androidrate:1.2.1"
    implementation 'com.github.THEAccess:SuspendRx:1.0.10'
    implementation 'com.github.THEAccess:privacydialog:0.1.0'
    implementation 'com.google.android.material:material:1.1.0-alpha04'
    implementation 'com.yqritc:android-scalablevideoview:1.0.4'
    implementation 'com.timqi.sectorprogressview:library:2.0.1'

    implementation 'com.github.Angtrim:Android-Five-Stars-Library:v3.1'
    implementation 'com.stepstone.apprating:app-rating:2.3.0'
    implementation 'com.google.firebase:firebase-dynamic-links:16.1.8'
    implementation 'com.google.firebase:firebase-ads:16.0.1'
    api ('com.google.android.ads.consent:consent-library:1.0.0') {
        exclude module: 'androidx.activity'
    }



    //Navigation
    implementation "android.arch.navigation:navigation-fragment-ktx:$nav_version"
    implementation "android.arch.navigation:navigation-ui-ktx:$nav_version"

    implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0'
    //Kodein
    def kodein_version = "6.0.1"
    implementation "org.kodein.di:kodein-di-generic-jvm:$kodein_version"
    implementation "org.kodein.di:kodein-di-framework-android-x:$kodein_version"
    implementation "org.kodein.di:kodein-di-conf-jvm:$kodein_version"

    //Firebase
    implementation 'com.google.firebase:firebase-core:16.0.7'
    implementation 'com.google.firebase:firebase-config:16.4.0'
    implementation 'com.google.firebase:firebase-perf:16.2.4'
    implementation 'com.google.firebase:firebase-firestore:18.1.0'
    implementation 'com.google.firebase:firebase-auth:16.2.0'
    implementation 'com.google.firebase:firebase-inappmessaging-display:17.1.0'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
        transitive = true;
    }
    implementation 'androidx.cardview:cardview:1.0.0'
}

Please help me understanding where the dependencies have duplicates

like image 947
Yannick Avatar asked Mar 27 '19 21:03

Yannick


2 Answers

I had the same problem. Just using the Clean Project option and building it again worked for me...

like image 169
Juan Diego Lozano Avatar answered Nov 17 '22 06:11

Juan Diego Lozano


It took me two days to fix it but here is the fix:

implementation ('com.google.android.ads.consent:consent-library:1.0.0') {
        exclude group: 'androidx'
    }
like image 24
Axes Grinds Avatar answered Nov 17 '22 07:11

Axes Grinds