A.Alqadomi
A.Alqadomi

Reputation: 1589

Migrating to Androidx Problem . multiple third-party libraries having "duplicate value for resource" issue

I am having problem in migrating to androidx due to third-party libraries inclusion in my gradle file . To locate the issue I have:

Output :

Android resource compilation failed
Output:  /Development/Android/trunk_deleteme/projects/MyApplication2/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:1550: error: duplicate value for resource 'attr/orientation' with config ''.
/Development/Android/trunk_deleteme/projects/MyApplication2/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:1550: error: resource previously defined here.
/Development/Android/trunk_deleteme/projects/MyApplication2/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:1816: error: duplicate value for resource 'attr/visibility' with config ''.
/Development/Android/trunk_deleteme/projects/MyApplication2/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:1816: error: resource previously defined here.

Command: /Users/a/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.1-4818971-osx.jar/2d51c190036eff4bb9de8b002a634480/aapt2-3.2.1-4818971-osx/aapt2 compile --legacy \
        -o \
        /Development/Android/trunk_deleteme/projects/MyApplication2/app/build/intermediates/res/merged/debug \
        /Development/Android/trunk_deleteme/projects/MyApplication2/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml
Daemon:  AAPT2 aapt2-3.2.1-4818971-osx Daemon #0

My Gradle file :

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {

    dexOptions {
        jumboMode true
    }


    compileSdkVersion 28
    defaultConfig {
        applicationId "com.a.myapplication"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.daimajia.slider:library:1.1.5@aar'
    implementation 'com.appeaser.sublimepickerlibrary:sublimepickerlibrary:2.1.2'

}

gradle.properties

org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
android.useAndroidX=true
android.enableJetifier=true

I know that these issues can be fixed from the third-party library owners but some of them will not provide new builds soon.

Question is :

is there away to fix these issue from my end instead of waiting for the third-party library owners to update their code ?

Edit: Following is a Part of the dependency tree

+--- com.appeaser.sublimepickerlibrary:sublimepickerlibrary:2.1.2
|    +--- androidx.appcompat:appcompat:1.0.0-rc01 -> 1.1.0-alpha01 (*)
|    +--- androidx.legacy:legacy-support-v4:1.0.0-rc01
|    |    +--- androidx.core:core:1.0.0-rc01 -> 1.1.0-alpha01 (*)
|    |    +--- androidx.media:media:1.0.0-rc01
|    |    |    +--- androidx.annotation:annotation:1.0.0-rc01 -> 1.0.0
|    |    |    +--- androidx.core:core:1.0.0-rc01 -> 1.1.0-alpha01 (*)
|    |    |    \--- androidx.versionedparcelable:versionedparcelable:1.0.0-rc01 -> 1.1.0-alpha01 (*)
|    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0-rc01 -> 1.0.0 (*)
|    |    +--- androidx.legacy:legacy-support-core-ui:1.0.0-rc01 -> 1.0.0 (*)
|    |    \--- androidx.fragment:fragment:1.0.0-rc01 -> 1.1.0-alpha02 (*)
|    +--- androidx.gridlayout:gridlayout:1.0.0-rc01
|    |    +--- androidx.core:core:1.0.0-rc01 -> 1.1.0-alpha01 (*)
|    |    \--- androidx.legacy:legacy-support-core-ui:1.0.0-rc01 -> 1.0.0 (*)
|    \--- androidx.annotation:annotation:1.0.0-rc01 -> 1.0.0
\--- androidx.multidex:multidex:2.0.0

Upvotes: 0

Views: 823

Answers (2)

Hamed Jaliliani
Hamed Jaliliani

Reputation: 2929

Change

implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'

to

-alpha2

Clead & rebuild :)

Upvotes: 2

Esperanz0
Esperanz0

Reputation: 1586

Did You tried after migration ?

- Clean and Build or gradle clean build assemble
- Invalidate and restart Android Studio

Upvotes: 0

Related Questions