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

fix(res): add missing namespace declarations #2102

Merged
merged 2 commits into from
Feb 15, 2024

Conversation

nitram84
Copy link
Contributor

Description

Steps to reproduce:

./gradlew assembleDebug

> Task :app:processDebugMainManifest
package="com.thiyagaraaj.learnpython" found in source AndroidManifest.xml: app/src/main/AndroidManifest.xml.
Setting the namespace via a source AndroidManifest.xml's package attribute is deprecated.
Please instead set the namespace (or testNamespace) in the module's build.gradle file, as described here: https://developer.android.com/studio/build/configure-app-module#set-namespace
This migration can be done automatically using the AGP Upgrade Assistant, please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.

> Task :app:mergeDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Multiple task action failures occurred:
   > A failure occurred while executing com.android.build.gradle.internal.res.ResourceCompilerRunnable
      > Resource compilation failed (Failed to compile resource file: app/src/main/res/layout/activity_group_list.xml: . Cause: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[82,47]
        Message: http://www.w3.org/TR/1999/REC-xml-names-19990114#AttributePrefixUnbound?com.google.android.gms.ads.AdView&ads:adSize&ads). Check logs for more details.
   > A failure occurred while executing com.android.build.gradle.internal.res.ResourceCompilerRunnable
      > Resource compilation failed (Failed to compile resource file: app/src/main/res/layout/activity_article_list.xml: . Cause: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[80,47]
        Message: http://www.w3.org/TR/1999/REC-xml-names-19990114#AttributePrefixUnbound?com.google.android.gms.ads.AdView&ads:adSize&ads). Check logs for more details.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED

The namespace "ads" was declared in a parent node below the root node, but declared namespaces are written only for the root node, so BinaryXMLParser.generateNameForNS() won't write a namespace declaration too. With this fix the grade build will pass all resource steps. The result is even better than apktool: In case of new namespaces apktool redeclares all namespaces.

PS: the check writer.getIndent() == 0 might not be necessary anymore

@skylot
Copy link
Owner

skylot commented Feb 15, 2024

@nitram84 thanks, look good 👍

@skylot skylot merged commit 13607fc into skylot:master Feb 15, 2024
5 checks passed
@nitram84 nitram84 deleted the missing_xml_namespaces branch March 18, 2024 10:25
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

Successfully merging this pull request may close these issues.

2 participants