Search code examples
gradleandroid-constraintlayoutandroid-studio-3.2android-studio-3.1.4android-studio-3.3

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


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?


Solution

  • 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.