Skip to content

[BUG]meta-data value in AndroidManifest.xml is incorrect with space after rebuilding #3898

@xigoEditer

Description

@xigoEditer

Information

  1. Apktool Version (apktool -version) - 2.11.1
  2. Operating System (Mac, Linux, Windows) - Windows
  3. APK From? (Playstore, ROM, Other) - build by myself
  4. Java Version (java --version) - 1.8

Stacktrace/Logcat

Include stacktrace here

Steps to Reproduce

  1. apktool d
  2. apktool b

Frameworks

If this APK is from an OEM ROM (Samsung, HTC, LG). Please attach framework files
(.apks that live in /system/framework or /system/priv-app)

APK

If this APK can be freely shared, please upload/attach a link to it.

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? yes
  2. If you are trying to install a modified apk, did you resign it? yes
  3. Are you using the latest apktool version? yes

In the class 'AndroidManifestResourceParser', there are some codes:

public String getAttributeValue(int index) {
        String value = super.getAttributeValue(index);
        if (value == null) {
            return "";
        }

        if (!isNumericStringMetadataAttributeValue(index, value)) {
            return value;
        }

        // Patch the numeric string value by prefixing it with an escaped space.
        // Otherwise, when the decoded app is rebuilt, aapt will incorrectly encode
        // the value as an int or float (depending on aapt version), breaking the original
        // app functionality.
        return "\\ " + value.trim();
    }

    private boolean isNumericStringMetadataAttributeValue(int index, String value) {
        return "meta-data".equals(super.getName())
                && "value".equals(super.getAttributeName(index))
                && super.getAttributeValueType(index) == TypedValue.TYPE_STRING
                && PATTERN_NUMERIC_STRING.matcher(value).matches();
    }

but,when i rebuild the apk,the value is incorrect with a space.

this is the meta-data value before decoding
Image

this is the meta-data value after rebuilding.
Image

Is this code still necessary?

return "\\ " + value.trim();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions