Build Failed because of duplicate value for resource 'attr/mode' with config

3k views Asked by At

after I upgraded constraintLayout version from 1.1.2 -> 2.0.0-alpha2

I'm getting this error

    java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
      /Users/x/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0-rc01.aar/
d5741c4d219b7f0eeb18436ff6f46f63/res/values/values.xml:1104:5-1169:25: AAPT: error: duplicate value for resource 'attr/mode' with config ''.

      /Users/x/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0-rc01.aar/
d5741c4d219b7f0eeb18436ff6f46f63/res/values/values.xml:1104:5-1169:25: AAPT: error: resource previously defined here.

appCompat version is v7:28.0.0-rc01

this issue is reproducible on AS 3.3 canary 3 & 3.2 stable & 3.1.4 & 3.0.1 version

how can I figure out this issue?

2

There are 2 answers

0
Kabliz On BEST ANSWER

The error message looks like the kind you can get if you mix Android X with Support Library, at least that is how it was when I found it.

If you use any Android X dependencies, you can't use any of the old Android Support Library dependencies, or else you're going to get duplicate resources and other problems when merging them all into one apk.

Make sure you are on either all Android X, or all Support Library. If you're moving to Android X, make sure you have

android.useAndroidX=true
android.enableJetifier=true

in your gradle.properties so that your other dependencies get treated as if they were Android X.

0
Martin Zeitler On

why you use appcompat-v7-28.0.0-rc01 instead of appcompat-v7-28.0.0 ?

or even androidx.appcompat:appcompat:1.0.0 ?

rc01 means release candidate; for testing purposes only.