Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Program type already present: androidx.asynclayoutinflater.R

I've tried upgrading my facebook sdk my app was using to the latest version (5.1.1), and it somehow took me down a rabbit hole of migrating my project to AndroidX. After doing the migration and ironing out some gradle issues, I now have a build issue Error: Program type already present: androidx.asynclayoutinflater.R

I've been trying to resolve my problem using this answer and other variants of it but Im finding it difficult to find which libraries are using androidx.asynclayoutinflater.R

when i dump out my dependancies i get this

+--- androidx.databinding:databinding-adapters:3.4.2@aar
+--- androidx.databinding:databinding-runtime:3.4.2@aar
+--- androidx.databinding:databinding-common:3.4.2@jar
+--- androidx.emoji:emoji-appcompat:1.0.0@aar
+--- com.codewaves.stickyheadergrid:stickyheadergrid:0.9.6@aar
+--- com.google.android.material:material:1.0.0@aar
+--- com.kishan.askpermission:askpermission:1.0.3@aar
+--- com.theartofdev.edmodo:android-image-cropper:2.8.0@aar
+--- uk.co.chrisjenx:calligraphy:2.3.0@aar
+--- com.facebook.android:facebook-android-sdk:5.1.1@aar
+--- com.facebook.android:facebook-login:5.1.1@aar
+--- com.facebook.android:facebook-share:5.1.1@aar
+--- com.facebook.android:facebook-common:5.1.1@aar
+--- androidx.appcompat:appcompat:1.0.2@aar
+--- androidx.browser:browser:1.0.0@aar
+--- androidx.cardview:cardview:1.0.0@aar
+--- androidx.constraintlayout:constraintlayout:1.1.3@aar
+--- androidx.gridlayout:gridlayout:1.0.0@aar
+--- androidx.legacy:legacy-support-v13:1.0.0@aar
+--- androidx.legacy:legacy-support-v4:1.0.0@aar
+--- com.andkulikov:transitionseverywhere:1.8.0@aar
+--- com.google.firebase:firebase-messaging:19.0.1@aar
+--- com.google.firebase:firebase-perf:18.0.1@aar
+--- com.github.bumptech.glide:glide:4.8.0@aar
+--- com.google.firebase:firebase-config:18.0.0@aar
+--- com.segment.analytics.android.integrations:firebase:1.3.1@jar
+--- com.google.firebase:firebase-core:17.0.1@aar
+--- com.google.firebase:firebase-analytics:17.0.0@aar
+--- com.google.android.gms:play-services-measurement-api:17.0.0@aar
+--- com.google.firebase:firebase-iid:19.0.1@aar
+--- com.google.firebase:firebase-abt:18.0.0@aar
+--- com.google.firebase:firebase-common:18.0.0@aar
+--- com.google.android.gms:play-services-clearcut:17.0.0@aar
+--- com.google.android.gms:play-services-phenotype:17.0.0@aar
+--- com.google.firebase:firebase-iid-interop:17.0.0@aar
+--- com.google.android.gms:play-services-base:17.0.0@aar
+--- com.google.android.gms:play-services-tasks:17.0.0@aar
+--- com.google.firebase:firebase-measurement-connector:18.0.0@aar
+--- com.google.android.gms:play-services-measurement:17.0.0@aar
+--- com.google.android.gms:play-services-measurement-sdk:17.0.0@aar
+--- com.google.android.gms:play-services-measurement-impl:17.0.0@aar
+--- com.google.android.gms:play-services-stats:17.0.0@aar
+--- com.google.android.gms:play-services-measurement-sdk-api:17.0.0@aar
+--- com.google.android.gms:play-services-measurement-base:17.0.0@aar
+--- com.google.android.gms:play-services-ads-identifier:17.0.0@aar
+--- com.google.android.gms:play-services-basement:17.0.0@aar
+--- androidx.fragment:fragment:1.0.0@aar
+--- androidx.vectordrawable:vectordrawable-animated:1.0.0@aar
+--- ca.barrenechea.header-decor:header-decor:0.2.8@aar
+--- androidx.recyclerview:recyclerview:1.0.0@aar
+--- androidx.legacy:legacy-support-core-ui:1.0.0@aar
+--- com.facebook.android:facebook-places:5.1.1@aar
+--- com.facebook.android:facebook-applinks:5.1.1@aar
+--- com.facebook.android:facebook-messenger:5.1.1@aar
+--- com.facebook.android:facebook-core:5.1.1@aar
+--- androidx.legacy:legacy-support-core-utils:1.0.0@aar
+--- androidx.vectordrawable:vectordrawable:1.0.1@aar
+--- androidx.emoji:emoji-bundled:1.0.0@aar
+--- androidx.emoji:emoji:1.0.0@aar
+--- androidx.media:media:1.0.0@aar
+--- androidx.transition:transition:1.0.0@aar
+--- androidx.loader:loader:1.0.0@aar
+--- androidx.viewpager:viewpager:1.0.0@aar
+--- androidx.coordinatorlayout:coordinatorlayout:1.0.0@aar
+--- androidx.drawerlayout:drawerlayout:1.0.0@aar
+--- androidx.slidingpanelayout:slidingpanelayout:1.0.0@aar
+--- androidx.customview:customview:1.0.0@aar
+--- androidx.swiperefreshlayout:swiperefreshlayout:1.0.0@aar
+--- androidx.asynclayoutinflater:asynclayoutinflater:1.0.0@aar
+--- androidx.core:core:1.0.2@aar
+--- androidx.multidex:multidex:2.0.1@aar
+--- com.anjlab.android.iab.v3:library:1.0.44@jar
+--- com.appsflyer:segment-android-integration:1.18@aar
+--- com.segment.analytics.android.integrations:mixpanel:2.1.0@jar
+--- com.segment.analytics.android:analytics:4.4.0-beta1@jar
+--- com.squareup.okhttp3:logging-interceptor:3.12.0@jar
+--- com.squareup.retrofit2:converter-gson:2.5.0@jar
+--- com.squareup.retrofit2:retrofit:2.5.0@jar
+--- io.branch.sdk.android:library:2.19.5@aar
+--- joda-time:joda-time:2.10.1@jar
+--- me.leolin:ShortcutBadger:1.1.21@aar
+--- me.relex:circleindicator:1.2.2@aar
+--- org.greenrobot:eventbus:3.1.1@jar
+--- se.emilsjolander:StickyScrollViewItems:1.1.0@aar
+--- com.crashlytics.sdk.android:crashlytics:2.7.1@aar
+--- androidx.test.espresso:espresso-idling-resource:3.2.0@aar
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31@jar
+--- com.jakewharton.rxbinding:rxbinding:0.3.0@aar
+--- androidx.lifecycle:lifecycle-runtime:2.0.0@aar
+--- androidx.versionedparcelable:versionedparcelable:1.0.0@aar
+--- androidx.collection:collection:1.0.0@jar
+--- androidx.cursoradapter:cursoradapter:1.0.0@aar
+--- androidx.interpolator:interpolator:1.0.0@aar
+--- com.github.bumptech.glide:gifdecoder:4.8.0@aar
+--- androidx.exifinterface:exifinterface:1.0.0@aar
+--- androidx.lifecycle:lifecycle-livedata:2.0.0@aar
+--- androidx.lifecycle:lifecycle-livedata-core:2.0.0@aar
+--- androidx.lifecycle:lifecycle-common:2.0.0@jar
+--- androidx.arch.core:core-runtime:2.0.0@aar
+--- androidx.arch.core:core-common:2.0.0@jar
+--- androidx.documentfile:documentfile:1.0.0@aar
+--- androidx.localbroadcastmanager:localbroadcastmanager:1.0.0@aar
+--- androidx.print:print:1.0.0@aar
+--- androidx.lifecycle:lifecycle-viewmodel:2.0.0@aar
+--- androidx.annotation:annotation:1.0.2@jar
+--- androidx.constraintlayout:constraintlayout-solver:1.1.3@jar
+--- com.appsflyer:af-android-sdk:4.10.0@aar
+--- com.github.bumptech.glide:disklrucache:4.8.0@jar
+--- com.github.bumptech.glide:annotations:4.8.0@jar
+--- com.squareup.okhttp3:okhttp:3.12.0@jar
+--- com.mixpanel.android:mixpanel-android:5.6.2@aar
+--- com.google.code.gson:gson:2.8.2@jar
+--- com.crashlytics.sdk.android:answers-shim:0.0.6@aar
+--- com.crashlytics.sdk.android:beta:1.2.7@aar
+--- com.crashlytics.sdk.android:crashlytics-core:2.4.1@aar
+--- com.crashlytics.sdk.android:answers:1.4.1@aar
+--- io.fabric.sdk.android:fabric:1.4.1@aar
+--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31@jar
+--- io.reactivex:rxjava:1.0.14@jar
+--- com.parse.bolts:bolts-android:1.4.0@jar
+--- com.google.zxing:core:3.3.3@jar
+--- com.google.auto.value:auto-value-annotations:1.6.3@jar
+--- com.squareup.okio:okio:1.15.0@jar
+--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31@jar
+--- org.jetbrains:annotations:13.0@jar
+--- com.parse.bolts:bolts-applinks:1.4.0@jar
\--- com.parse.bolts:bolts-tasks:1.4.0@jar

which shows the line +--- androidx.asynclayoutinflater:asynclayoutinflater:1.0.0@aar only once (well once per product flavor/build type)

update: found a more tree like dependency graph, here is a snippet but there is a huge amount of this stuff, cant even paste it on pastebin there is so much

+--- androidx.appcompat:appcompat:1.0.2
|    +--- androidx.fragment:fragment:1.0.0
|    |    +--- androidx.core:core:1.0.0 -> 1.0.2 (*)
|    |    +--- androidx.legacy:legacy-support-core-ui:1.0.0
|    |    |    +--- androidx.asynclayoutinflater:asynclayoutinflater:1.0.0
|    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    |    |    \--- androidx.core:core:1.0.0 -> 1.0.2 (*)

tried removing these which seemed to have no effect

implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'

my dependencies look like this

dependencies {
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.browser:browser:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.core:core:1.0.2'
    implementation 'androidx.emoji:emoji-appcompat:1.0.0'
    implementation 'androidx.emoji:emoji-bundled:1.0.0'
    implementation 'androidx.gridlayout:gridlayout:1.0.0'
    implementation 'androidx.legacy:legacy-support-v13:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'ca.barrenechea.header-decor:header-decor:0.2.8'
    implementation 'com.andkulikov:transitionseverywhere:1.8.0'
    implementation 'com.anjlab.android.iab.v3:library:1.0.44'
    implementation 'com.appsflyer:segment-android-integration:1.+'
    implementation 'com.codewaves.stickyheadergrid:stickyheadergrid:0.9.6'
    implementation 'com.facebook.android:facebook-android-sdk:5.1.1'
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'com.google.firebase:firebase-core:17.0.1'
    implementation 'com.google.firebase:firebase-messaging:19.0.1'
    implementation 'com.google.firebase:firebase-perf:18.0.1'
    implementation 'com.kishan.askpermission:askpermission:1.0.3'
    implementation 'com.segment.analytics.android.integrations:firebase:1.3.1'
    implementation 'com.segment.analytics.android.integrations:mixpanel:2.1.0'
    implementation 'com.segment.analytics.android:analytics:4.+'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.12.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
    implementation 'com.squareup.retrofit2:retrofit:2.5.0'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
    implementation 'io.branch.sdk.android:library:2.+'
    implementation 'joda-time:joda-time:2.10.1'
    implementation 'me.leolin:ShortcutBadger:1.1.21@aar'
    implementation 'me.relex:circleindicator:1.2.2@aar'
    implementation 'org.greenrobot:eventbus:3.1.1'
    implementation 'se.emilsjolander:StickyScrollViewItems:1.1.0'
    implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
        transitive = true;
    }
    kapt 'com.github.bumptech.glide:compiler:4.8.0'

    //---Testing---
    testImplementation 'junit:junit:4.12'
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    androidTestImplementation('androidx.test.espresso:espresso-contrib:3.1.0') {
        exclude group: 'com.android.support', module: 'appcompat'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude module: 'recyclerview-v7'
    }
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0'
    implementation 'androidx.test.espresso:espresso-idling-resource:3.2.0'
    androidTestImplementation 'androidx.test:rules:1.2.0'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestUtil 'androidx.test:orchestrator:1.2.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31"
    implementation 'com.jakewharton.rxbinding:rxbinding:0.3.0'
    //-------------
}

I've also tried to force the support library version, not sure if this has any usefulness or if im doing it wrong, but i saw it was suggested in a post here on SO

final SUPPORT_LIB_VER = '28.0.0'

configurations.all {
    resolutionStrategy {
        force "com.android.support:appcompat-v7:${SUPPORT_LIB_VER}"
        force "com.android.support:support-v4:${SUPPORT_LIB_VER}"
    }
}

I also have this in my gradle.properties

android.enableJetifier=true
android.useAndroidX=true

Does anyone know an easy way to find what is using this particular dependancy so i can try resolve the duplication, or just know what library might be causing it?

like image 302
Fonix Avatar asked Dec 10 '22 02:12

Fonix


1 Answers

So after days of suffering I finally found the issue

i had to change

implementation 'com.segment.analytics.android.integrations:firebase:1.3.1'

to

implementation 'com.segment.analytics.android.integrations:firebase:1.3.1@aar'

fml

The easiest way to trouble shoot this i found was to make a clean new android project and put all your dependencies from your main project in there and use divide and conquer to pin point which library is causing the issue specifically. Found a random 0 rating answer that suggested putting @aar on the end without an explanation, and it worked.

like image 124
Fonix Avatar answered Feb 13 '23 04:02

Fonix