question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Material components fails automatic namespaced resources due to malformed public.txt

See original GitHub issue

Description:

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:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
dsn5ftcommented, Aug 4, 2020

Looks like this is because a few places in res-public use type="reference" instead of type="attr". Will submit the fix.

1reaction
matpagcommented, Aug 4, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting - Unity - Manual
This error message indicates that your manifest.json file is malformed. It also tells you the line number where the Package Manager failed ...
Read more >
Automatic Certificate Management Environment (ACME)
A deactivated account can no longer request certificate issuance or access resources related to the account, such as orders or authorizations. If a...
Read more >
TextView - Android Developers
An editable text view that shows completion suggestions automatically while the ... android:autoSizePresetSizes, Resource array of dimensions to be used in ...
Read more >
Form.AutoSize Property (System.Windows.Forms)
true if the form will automatically resize; false if it must be manually resized. Attributes. BrowsableAttribute. Examples. The following example shows a form ......
Read more >
RFC 6241: Network Configuration Protocol (NETCONF)
This section discusses a small number of XML-related considerations pertaining to NETCONF. 3.1. Namespace All NETCONF protocol elements are defined in the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found