iBotPeaches / Apktool

A tool for reverse engineering Android apk files

Home Page:https://apktool.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG]Using aapt2 to export packages, extra spaces appear in the meta-data value in AndroidManifest

yangbo637829 opened this issue · comments

Information

  1. Apktool Version (apktool -version) -2.9.3
  2. Operating System (Mac, Linux, Windows) - mac
  3. APK From? (Playstore, ROM, Other) - playstore
  4. Java Version (java --version) - java11

Bug

When the meta-data in AndroidManifest contains a numeric string, there will be an extra space in front of the value of this field in the new package built.

My fix suggestion

The new version of apktool uses aapt2 for packaging by default, resulting in spaces added when parsing the AndroidManifest that cannot be eliminated. Turn off aapt2 and use aapt1 to create new packages without this problem.

When parsing AndroidManifest, you can decide whether to add spaces in front of numeric strings according to the version of aapt.

code: brut.androlib.res.data.value.ResStringValue#checkIfStringIsNumeric

The code here needs to be modified to solve the problem of test cases failing to pass:
brut.apktool/apktool-lib/src/test/resources/aapt2/testapp/AndroidManifest.xml
image

This is a known issue still. We don't have the knowledge of whether aapt2/aapt1 is in play during the checkIfStringIsNumeric check to properly avoid this.

#2634

I'll close for existing issue.