material-components / material-components-android

Modular and customizable Material Design UI components for Android
Apache License 2.0
16.31k stars 3.06k forks source link

compile error due to resources not being prefixed #1146

Closed JensBoeykens closed 2 years ago

JensBoeykens commented 4 years ago

When integrating a dependency that was using this material component we encountered a compile issue caused by an attribute not being prefixed:

.gradle/caches/transforms-1/files-1.1/jetified-play-services-base-16.0.1.aar/e61bb1920da7a4a8820cc6b87660c38e/res/values/values.xml:47:1-65:21: AAPT: error: duplicate value for resource ‘attr/cornerSize’ with config ‘’. .gradle/caches/transforms-1/files-1.1/jetified-play-services-base-16.0.1.aar/e61bb1920da7a4a8820cc6b87660c38e/res/values/values.xml:47:1-65:21: AAPT: error: resource previously defined here.

We had to exclude this material component from the dependency we added because of this. Can you prefix these attributes please so it won't cause duplicate values with resources from play-services-base?

wcshi commented 4 years ago

@JensBoeykens what versions of the play-services-base lib and Material lib are you using?

JensBoeykens commented 4 years ago

Problem was with ‘com.google.android.material:material:1.1.0’ and 'com.google.android.gms:play-services-base:16.0.1'

wcshi commented 4 years ago

Could you please test using the latest version of 'com.google.android.gms:play-services-base' (which should appears to be 17.2.0) and let us know if it's still a problem?

JensBoeykens commented 4 years ago

Tested with 17.2.0 and same error:

`* What went wrong: Execution failed for task ':app:mergeDebugResources'.

java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
.gradle/caches/transforms-1/files-1.1/play-services-base-17.2.0.aar/62f7de36c18e5ebf0ff22e5a9f7bf84e/res/values/values.xml:47:1-65:21: AAPT: error: duplicate value for resource 'attr/cornerSize' with config ''.

.gradle/caches/transforms-1/files-1.1/play-services-base-17.2.0.aar/62f7de36c18e5ebf0ff22e5a9f7bf84e/res/values/values.xml:47:1-65:21: AAPT: error: resource previously defined here. `

wcshi commented 4 years ago

Changing the attribute name is considered an api change, so unfortunately we would need to wait till the next major release (2.x.y).

In the meantime, could you file a bug on the play services base lib to see if they can confirm that they have the same attribute name? We suspect that they might be depending on an internal version of our lib that is different than your gradle build.

JensBoeykens commented 4 years ago

ok, we'll wait for the next major release.

Looking at the dependency graph of play-services-base, they don't seem to be depending on your lib:

\--- com.google.android.gms:play-services-base:17.2.0 +--- androidx.collection:collection:1.0.0 | \--- androidx.annotation:annotation:1.0.0 +--- androidx.core:core:1.0.0 | +--- androidx.annotation:annotation:1.0.0 | +--- androidx.collection:collection:1.0.0 (*) | +--- androidx.lifecycle:lifecycle-runtime:2.0.0 | | +--- androidx.lifecycle:lifecycle-common:2.0.0 | | | \--- androidx.annotation:annotation:1.0.0 | | +--- androidx.arch.core:core-common:2.0.0 | | | \--- androidx.annotation:annotation:1.0.0 | | \--- androidx.annotation:annotation:1.0.0 | \--- androidx.versionedparcelable:versionedparcelable:1.0.0 | +--- androidx.annotation:annotation:1.0.0 | \--- androidx.collection:collection:1.0.0 (*) +--- androidx.fragment:fragment:1.0.0 | +--- androidx.core:core:1.0.0 (*) | +--- androidx.legacy:legacy-support-core-ui:1.0.0 | | +--- androidx.annotation:annotation:1.0.0 | | +--- androidx.core:core:1.0.0 (*) | | +--- androidx.legacy:legacy-support-core-utils:1.0.0 | | | +--- androidx.annotation:annotation:1.0.0 | | | +--- androidx.core:core:1.0.0 (*) | | | +--- androidx.documentfile:documentfile:1.0.0 | | | | \--- androidx.annotation:annotation:1.0.0 | | | +--- androidx.loader:loader:1.0.0 | | | | +--- androidx.annotation:annotation:1.0.0 | | | | +--- androidx.core:core:1.0.0 (*) | | | | +--- androidx.lifecycle:lifecycle-livedata:2.0.0 | | | | | +--- androidx.arch.core:core-runtime:2.0.0 | | | | | | +--- androidx.annotation:annotation:1.0.0 | | | | | | \--- androidx.arch.core:core-common:2.0.0 (*) | | | | | +--- androidx.lifecycle:lifecycle-livedata-core:2.0.0 | | | | | | +--- androidx.lifecycle:lifecycle-common:2.0.0 (*) | | | | | | +--- androidx.arch.core:core-common:2.0.0 (*) | | | | | | \--- androidx.arch.core:core-runtime:2.0.0 (*) | | | | | \--- androidx.arch.core:core-common:2.0.0 (*) | | | | \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0 | | | | \--- androidx.annotation:annotation:1.0.0 | | | +--- androidx.localbroadcastmanager:localbroadcastmanager:1.0.0 | | | | \--- androidx.annotation:annotation:1.0.0 | | | \--- androidx.print:print:1.0.0 | | | \--- androidx.annotation:annotation:1.0.0 | | +--- androidx.customview:customview:1.0.0 | | | +--- androidx.annotation:annotation:1.0.0 | | | \--- androidx.core:core:1.0.0 (*) | | +--- androidx.viewpager:viewpager:1.0.0 | | | +--- androidx.annotation:annotation:1.0.0 | | | +--- androidx.core:core:1.0.0 (*) | | | \--- androidx.customview:customview:1.0.0 (*) | | +--- androidx.coordinatorlayout:coordinatorlayout:1.0.0 | | | +--- androidx.annotation:annotation:1.0.0 | | | +--- androidx.core:core:1.0.0 (*) | | | \--- androidx.customview:customview:1.0.0 (*) | | +--- androidx.drawerlayout:drawerlayout:1.0.0 | | | +--- androidx.annotation:annotation:1.0.0 | | | +--- androidx.core:core:1.0.0 (*) | | | \--- androidx.customview:customview:1.0.0 (*) | | +--- androidx.slidingpanelayout:slidingpanelayout:1.0.0 | | | +--- androidx.annotation:annotation:1.0.0 | | | +--- androidx.core:core:1.0.0 (*) | | | \--- androidx.customview:customview:1.0.0 (*) | | +--- androidx.interpolator:interpolator:1.0.0 | | | \--- androidx.annotation:annotation:1.0.0 | | +--- androidx.swiperefreshlayout:swiperefreshlayout:1.0.0 | | | +--- androidx.annotation:annotation:1.0.0 | | | +--- androidx.core:core:1.0.0 (*) | | | \--- androidx.interpolator:interpolator:1.0.0 (*) | | +--- androidx.asynclayoutinflater:asynclayoutinflater:1.0.0 | | | +--- androidx.annotation:annotation:1.0.0 | | | \--- androidx.core:core:1.0.0 (*) | | \--- androidx.cursoradapter:cursoradapter:1.0.0 | | \--- androidx.annotation:annotation:1.0.0 | +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*) | +--- androidx.annotation:annotation:1.0.0 | +--- androidx.loader:loader:1.0.0 (*) | \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0 (*) +--- com.google.android.gms:play-services-basement:17.2.0 | +--- androidx.collection:collection:1.0.0 (*) | +--- androidx.core:core:1.0.0 (*) | \--- androidx.fragment:fragment:1.0.0 (*) \--- com.google.android.gms:play-services-tasks:17.0.0 \--- com.google.android.gms:play-services-basement:17.0.0 -> 17.2.0 (*)

sabinebarrera commented 4 years ago

@wcshi I am having the same problem:

What went wrong * res/values/values.xml:33:5-494: AAPT: error: duplicate value for resource 'attr/horizontalOffset' with config '' * res/values/values.xml:33:5-494: AAPT: error: resource previously defined here * res/values/values.xml:33:5-494: AAPT: error: duplicate value for resource 'attr/verticalOffset' with config ''. * mergeDebugResources/merged.dir/values/values.xml: error: file failed to compile.

I need to use the com.google.android.material:material:1.3.0-alpha01 because of the updates in the TextInputLayout that allow me to achieve my design:

I don't have any horizontalOffset or verticalOffset in my app. Is there a work around?

drchen commented 2 years ago

Is this still an issue?

drchen commented 2 years ago

I'll close this issue for now due to no further info available. Please feel free to reopen it if this is still an issue.