Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade 1.1.3 to 2.0.* fails. AAPT: error: duplicate value for resource #111

Closed
mortenholmgaard opened this issue Jan 19, 2021 · 8 comments

Comments

@mortenholmgaard
Copy link

mortenholmgaard commented Jan 19, 2021

I am trying to upgrade from 1.1.3 to 2.0.* but keeps getting those errors. Have tried with multiple versions but only 1.1.3 seems to compile.
First/main error seems to be this:

AAPT: error: duplicate value for resource 'attr/defaultState' with config ''

It relates to this line in values.xml:
<declare-styleable name="StateSet"><attr format="reference" name="defaultState"/></declare-styleable>

> Task :app:mergeDevelopmentResources
AGPBI: {"kind":"error","text":"Android resource compilation failed","sources":[{"file":"C:\\Users\\xxx\\.gradle\\caches\\transforms-2\\files-2.1\\ac7a3722485ab8c9a6b5e513552ba699\\constraintlayout-2.0.4\\res\\values\\values.xml","position":{"startLine":340,"startColumn":4,"startOffset":35314,"endColumn":105,"endOffset":35415}}],"original":"C:\\Users\\xxx\\.gradle\\caches\\transforms-2\\files-2.1\\ac7a3722485ab8c9a6b5e513552ba699\\constraintlayout-2.0.4\\res\\values\\values.xml:341:5-106: AAPT: error: duplicate value for resource 'attr/defaultState' with config ''.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource compilation failed","sources":[{"file":"C:\\Users\\xxx\\.gradle\\caches\\transforms-2\\files-2.1\\ac7a3722485ab8c9a6b5e513552ba699\\constraintlayout-2.0.4\\res\\values\\values.xml","position":{"startLine":340,"startColumn":4,"startOffset":35314,"endColumn":105,"endOffset":35415}}],"original":"C:\\Users\\xxx\\.gradle\\caches\\transforms-2\\files-2.1\\ac7a3722485ab8c9a6b5e513552ba699\\constraintlayout-2.0.4\\res\\values\\values.xml:341:5-106: AAPT: error: resource previously defined here.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource compilation failed","sources":[{"file":"C:\\Code\\xxx\\app\\build\\intermediates\\incremental\\mergeDevelopmentResources\\merged.dir\\values\\values.xml"}],"original":"C:\\Code\\xxx\\app\\build\\intermediates\\incremental\\mergeDevelopmentResources\\merged.dir\\values\\values.xml: AAPT: error: file failed to compile.\n    ","tool":"AAPT"}

Any one that could see what could cause this issue?
It could seem to be some kind of denpendency versions conflict, but still can't get why this would end up in something like this.

Edit:
I found out that the material dependency is part of the problem:

implementation 'com.google.android.material:material:1.2.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

When ever I either upgrade that material to latest version or constraintlayout to 2.0.* it results in the above error, also if both are upgraded. Only with the versions above does it work. How could this be?

@jafu888
Copy link
Collaborator

jafu888 commented Jan 20, 2021

This is a constant problem in Android.
Attributes do not have name spaces. Attributes of the same name must have the same type.

All libraries need to be carful.
Our approach:

  1. Use 2 word names (motionProgress not progress)
  2. If we get a report before we release we change the attribute.

1.1.3 was release in August 2018
So we are well pass that.

@kaeawc
Copy link
Contributor

kaeawc commented Jan 23, 2021

Material Design 1.2.x depends on ConstraintLayout 1.1.3
Material Design 1.3.0-alpha02 included an upgrade to depend on ContraintLayout 2.x

Because of changes in ConstraintLayout attrs during the 2.x migration, this means that using Material Design 1.2.x with ConstraintLayout 2.x is just not possible.

@mortenholmgaard
Copy link
Author

mortenholmgaard commented Jan 26, 2021

Haven't tried with 1.3.0-* before, but that still doesn't work..
I get exactly the same error with those references:

implementation 'com.google.android.material:material:1.3.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4' // also tried with 2.0.1 which should be exactly what material is using but doesn't work either.

@jafu888
Copy link
Collaborator

jafu888 commented Jan 26, 2021

Have you tried contacting the material team ?

@xuyisheng
Copy link

I meet the same error with constraintlayout:2.1.0-alpha2 and material:1.2.0

@kaeawc
Copy link
Contributor

kaeawc commented Jan 28, 2021

@xuyisheng @mortenholmgaard what versions are you running of Android Studio & AGP? On 4.1.1 and 4.1.2 and the Arctic Fox canaries I'm not seeing the issue you describe with these versions:

implementation 'com.google.android.material:material:1.3.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 

@mortenholmgaard
Copy link
Author

I am running Android Studio 4.1.2 and AGP 4.1.2.

I tried making a sample project for the case but saw that it worked then. So after some elimination of the other included libaries I figured out that the conflict was with this: miguelhincapie/CustomBottomSheetBehavior#85

@OmidAmirii
Copy link

have resolved it by renaming the attr name

attr name="fontTest" format="integer"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants