gregkorossy/Android-Support-Preference-V7-Fix

Error: duplicate value for resource attr/maxWidth

eriknyk opened this issue · 6 comments

I'm getting the following error:

:generateDebugResources UP-TO-DATE
AGPBI: {"kind":"error","text":"error: duplicate value for resource \u0027attr/maxWidth\u0027 with config \u0027\u0027.","sources":[{"file":"/Users/erik/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/de16534766b25cf86037771b3f3fc3f7/res/values/values.xml","position":{"startLine":250,"startColumn":4,"startOffset":27058,"endColumn":68,"endOffset":27122}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource previously defined here.","sources":[{"file":"/Users/erik/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/de16534766b25cf86037771b3f3fc3f7/res/values/values.xml","position":{"startLine":250,"startColumn":4,"startOffset":27058,"endColumn":68,"endOffset":27122}}],"original":"","tool":"AAPT"}
:mergeDebugResources
Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
:mergeDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details

my build.gradle has all those android.support includes

    implementation "com.android.support:support-v4:27.1.1"
    implementation "com.android.support:support-v13:27.1.1"
    implementation "com.android.support:cardview-v7:27.1.1"
    implementation "com.android.support:appcompat-v7:27.1.1"
    implementation "com.android.support:design:27.1.1"
    // implementation "com.android.support:preference-v7:27.1.1"
    implementation 'com.takisoft.fix:preference-v7:27.1.1.0'

I will appreciate any help about this,
Regards!

This is not the lib's fault. You can try a few things to overcome this:

  1. Clean and rebuild project, preferably with invalidating caches
  2. Check if you have different versions of the support libs (or a lib that includes a different version of a support lib).
  3. Maybe a different library uses its own maxWidth attribute.

Also, I don't see maxWidth as a declared attribute in any of the modules / dependencies. Are you sure this problem is related to this lib?

Thanks @gericop, If I comment the line:

implementation 'com.takisoft.fix:preference-v7:27.1.1.0'

The gradle build finish successfully.

Also I already tried your three suggestion points but with not luck.

Regards.

Since I cannot reproduce this issue with the sample app or any of my apps using this lib, there are a couple questions:

  • What other dependencies do you include?
  • What is the version of Android Studio?
  • What is the version of the gradle plugin?

Thanks @Gericop those are all dependencies that actually I'm using:
https://github.com/eriknyk/testapp/blob/master/app/build.gradle#L32

this https://github.com/eriknyk/testapp/ is a empty project and i've got same error.

:app:generateDebugResources UP-TO-DATE
AGPBI: {"kind":"error","text":"error: duplicate value for resource \u0027attr/maxWidth\u0027 with config \u0027\u0027.","sources":[{"file":"/Users/erik/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/de16534766b25cf86037771b3f3fc3f7/res/values/values.xml","position":{"startLine":250,"startColumn":4,"startOffset":27058,"endColumn":68,"endOffset":27122}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource previously defined here.","sources":[{"file":"/Users/erik/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/de16534766b25cf86037771b3f3fc3f7/res/values/values.xml","position":{"startLine":250,"startColumn":4,"startOffset":27058,"endColumn":68,"endOffset":27122}}],"original":"","tool":"AAPT"}
:app:mergeDebugResources
Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
:app:mergeDebugResources FAILED

First of all, most of your dependencies are outdated (some are even deprecated, like the nineoldandroids or the ViewPagerIndicator ones).
However, the problem lies within the "signature pad" module. The version you use is 1.0.1 while the latest is 1.2.1. Using the latest version eliminates the error and the build completes without any errors.

This lib does not declare the "maxWidth" attribute per se anywhere but one of the dependencies does (I think it's one of the preferences) and that collides with the old version of that signature pad lib.

@Gericop YOU ARE THE MAN!
THANK YOU very very much!!!