Material components fails automatic namespaced resources due to malformed public.txt
See original GitHub issueDescription:
When enabling namespaced resources in AGP 4.1, material components causes the build to fail
> Failed to transform material-1.2.0-beta01.aar (com.google.android.material:material:1.2.0-beta01) to match attributes {artifactType=android-symbol-with-package-name, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for AutoNamespaceTransform: /Users/zsweers/.gradle/caches/transforms-2/files-2.1/bc56df301aa7a093beed88eff5a85463/com.google.android.material.
> Failed to auto-namespace com.google.android.material
This appears to be because it ships with a public.txt
file in the aar with reference
types, which are not a valid ResourceType
. I believe this is coming from attrs.xml
files
reference popupMenuBackground
reference values
These come from here: https://github.com/material-components/material-components-android/blob/147620fc10694b9756f24746b7428a62fa4264ef/lib/java/com/google/android/material/menu/res/values/attrs.xml#L20 https://github.com/material-components/material-components-android/blob/5fb796437291ce6b7d43b3beba13a42256db6eac/lib/java/com/google/android/material/slider/res/values/attrs.xml#L67
Which eventually leads to this exception in AGP
Caused by: java.io.IOException: Invalid resource type reference
at com.android.ide.common.symbols.SymbolIo.readPublicTxtLine(SymbolIo.java:677)
at com.android.ide.common.symbols.SymbolIo.access$600(SymbolIo.java:106)
at com.android.ide.common.symbols.SymbolIo$ReadConfiguration$6.parseLine(SymbolIo.java:789)
at com.android.ide.common.symbols.SymbolIo$SymbolLineReader.readLines(SymbolIo.java:402)
... 115 more
Expected behavior: The library should ship valid a valid public.txt
in its AAR
Source code: Try to use material components in a project with namespaced resources available. AGP will fail when it runs its auto-namespace transform
Android API version: N/A build-time
Material Library version: All of them and on master currently.
Device: N/A
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
Looks like this is because a few places in
res-public
usetype="reference"
instead oftype="attr"
. Will submit the fix.Thank you for the input, probably is this one: https://developer.android.com/reference/tools/gradle-api/com/android/build/api/dsl/AaptOptions#namespaced will test this tonight