REAndroid / APKEditor

Powerful android apk editor - aapt/aapt2 independent
Apache License 2.0
931 stars 143 forks source link

Spam of xmlns in AndroidManifest.xml #128

Closed Veha0001 closed 1 month ago

Veha0001 commented 1 month ago

Describe the bug I tried to decompile an APK and then rebuild it without making any changes to the files. After installing, I checked the AndroidManifest.xml in the APK file that I just built and saw this: Screenshot_2024-09-23-19-03-36-59_9bde489fb18d43e8729607528f1e9d52

xmlns:android="http://schemas.android.com/apk/res/android" Original: Screenshot_2024-09-23-20-45-21-94_9bde489fb18d43e8729607528f1e9d52

To Reproduce Steps to reproduce the behavior:

  1. Used version 'v1.3.9
  2. Operating system 'Termux(android), and Windows'
  3. Command 'apkedit b -i . -o app.apk'
  4. Install the rebuilt APK.
  5. Check the AndroidManifest.xml in the rebuilt APK.
REAndroid commented 1 month ago

I can't tell the problem without sample, my blind guess is that APKEditor tried to fix malformed namespaces caused by proguard or other obfuscators

Veha0001 commented 1 month ago
➜  Downloads pwd
/data/data/com.termux/files/home/Downloads
➜  Downloads ls
rsdkv5u_mania.apk
➜  Downloads which apkedit
apkedit: aliased to java -jar /data/data/com.termux/files/home/.l
ocal/bin/APKEditor.jar
➜  Downloads apkedit d *.apk -o rsdkv
Unknown option: 'rsdkv5u_mania.apk'
➜  Downloads apkedit d -i *.apk -o apkdir
00.000 I: [DECOMPILE] Using: APKEditor version 1.3.9, ARSCLib ver
sion 1.3.5
      -t = xml
      -i = rsdkv5u_mania.apk
      -o = apkdir
 __________________________
00.113 I: [DECOMPILE] Loading ...
00.549 I: [DECOMPILE] Decompiling to xml ...
00.923 I: [DECOMPILE] Initializing android framework ...
00.924 I: [DECOMPILE] Loading android framework for version: 33
01.247 I: [DECOMPILE] Initialized framework: android-33 (UpsideDo
wnCake)
01.299 I: [DECOMPILE] [SANITIZE]: Sanitizing paths ...
01.328 I: [DECOMPILE] Validating resource names ...
01.409 I: [DECOMPILE] All resource names are valid
01.410 I: [DECOMPILE] Decode: archive-info.json
01.433 I: [DECOMPILE] Decode: uncompressed-files.json
01.497 I: [DECOMPILE] Decoding: AndroidManifest.xml
01.599 I: [DECOMPILE] public.xml: org.rems.rsdkv5 -> package_1
01.632 I: [DECOMPILE] Res files: resources
03.460 I: [DECOMPILE] Baksmali: classes.dex
18.110 I: [DECOMPILE] Extracting root files ...
18.591 I: [DECOMPILE] Dumping signatures ...
18.593 I: [DECOMPILE] Saved to: apkdir
➜  Downloads aapt d xmltree *.apk AndroidManifest.xml
N: android=http://schemas.android.com/apk/res/android
  E: manifest (line=2)
    A: android:versionCode(0x0101021b)=(type 0x10)0x64
    A: android:versionName(0x0101021c)="1.1.0" (Raw: "1.1.0")
    A: android:installLocation(0x010102b7)=(type 0x10)0x0
    A: android:compileSdkVersion(0x01010572)=(type 0x10)0x21
    A: android:compileSdkVersionCodename(0x01010573)="13" (Raw: "
13")
    A: package="org.rems.rsdkv5" (Raw: "org.rems.rsdkv5")
    A: platformBuildVersionCode=(type 0x10)0x21
    A: platformBuildVersionName=(type 0x10)0xd
    E: uses-sdk (line=8)
      A: android:minSdkVersion(0x0101020c)=(type 0x10)0x15
      A: android:targetSdkVersion(0x01010270)=(type 0x10)0x21
    E: uses-feature (line=12)
      A: android:glEsVersion(0x01010281)=(type 0x11)0x20000
    E: uses-feature (line=13)
      A: android:name(0x01010003)="android.hardware.touchscreen" 
(Raw: "android.hardware.touchscreen")
      A: android:required(0x0101028e)=(type 0x12)0x0
    E: uses-feature (line=16)
      A: android:name(0x01010003)="android.hardware.bluetooth" (R
aw: "android.hardware.bluetooth")
      A: android:required(0x0101028e)=(type 0x12)0x0
    E: uses-feature (line=19)
      A: android:name(0x01010003)="android.hardware.gamepad" (Raw
: "android.hardware.gamepad")
      A: android:required(0x0101028e)=(type 0x12)0x0
    E: uses-feature (line=22)
      A: android:name(0x01010003)="android.hardware.usb.host" (Ra
w: "android.hardware.usb.host")
      A: android:required(0x0101028e)=(type 0x12)0x0
    E: uses-feature (line=25)
      A: android:name(0x01010003)="android.hardware.type.pc" (Raw
: "android.hardware.type.pc")
      A: android:required(0x0101028e)=(type 0x12)0x0
    E: uses-permission (line=29)
      A: android:name(0x01010003)="android.permission.WRITE_EXTER
NAL_STORAGE" (Raw: "android.permission.WRITE_EXTERNAL_STORAGE")
      A: android:maxSdkVersion(0x01010271)=(type 0x10)0x1e
    E: uses-permission (line=32)
      A: android:name(0x01010003)="android.permission.MANAGE_EXTE
RNAL_STORAGE" (Raw: "android.permission.MANAGE_EXTERNAL_STORAGE")
    E: uses-permission (line=33)
      A: android:name(0x01010003)="android.permission.READ_EXTERN
AL_STORAGE" (Raw: "android.permission.READ_EXTERNAL_STORAGE")
    E: uses-permission (line=34)
      A: android:name(0x01010003)="android.permission.BLUETOOTH" 
(Raw: "android.permission.BLUETOOTH")
    E: permission (line=36)
      A: android:name(0x01010003)="org.rems.rsdkv5.DYNAMIC_RECEIV
ER_NOT_EXPORTED_PERMISSION" (Raw: "org.rems.rsdkv5.DYNAMIC_RECEIV
ER_NOT_EXPORTED_PERMISSION")
      A: android:protectionLevel(0x01010009)=(type 0x11)0x2
    E: uses-permission (line=40)
      A: android:name(0x01010003)="org.rems.rsdkv5.DYNAMIC_RECEIV
ER_NOT_EXPORTED_PERMISSION" (Raw: "org.rems.rsdkv5.DYNAMIC_RECEIV
ER_NOT_EXPORTED_PERMISSION")
    E: application (line=41)
      A: android:label(0x01010001)=@0x7f0d001c
      A: android:icon(0x01010002)=@0x7f0c0000
      A: android:allowBackup(0x01010280)=(type 0x12)0xffffffff
      A: android:hardwareAccelerated(0x010102d3)=(type 0x12)0xfff
fffff
      A: android:extractNativeLibs(0x010104ea)=(type 0x12)0xfffff
fff
      A: android:appComponentFactory(0x0101057a)="androidx.core.a
pp.CoreComponentFactory" (Raw: "androidx.core.app.CoreComponentFa
ctory")
      E: activity (line=48)
        A: android:theme(0x01010000)=@0x7f0e00fd
        A: android:label(0x01010001)=@0x7f0d001c
        A: android:icon(0x01010002)=@0x7f0c0000
        A: android:name(0x01010003)="org.rems.rsdkv5.Launcher" (R
aw: "org.rems.rsdkv5.Launcher")
        A: android:exported(0x01010010)=(type 0x12)0xffffffff
        E: intent-filter (line=54)
          E: action (line=55)
            A: android:name(0x01010003)="android.intent.action.MA
IN" (Raw: "android.intent.action.MAIN")
          E: category (line=57)
            A: android:name(0x01010003)="android.intent.category.
LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
      E: activity (line=60)
        A: android:theme(0x01010000)=@0x7f0e0005
        A: android:icon(0x01010002)=@0x7f0c0000
        A: android:name(0x01010003)="org.rems.rsdkv5.RSDK" (Raw: 
"org.rems.rsdkv5.RSDK")
        A: android:exported(0x01010010)=(type 0x12)0xffffffff
        A: android:launchMode(0x0101001d)=(type 0x10)0x3
        A: android:screenOrientation(0x0101001e)=(type 0x10)0x6
        A: android:configChanges(0x0101001f)=(type 0x11)0x4a0
        A: android:alwaysRetainTaskState(0x01010203)=(type 0x12)0
xffffffff
        E: intent-filter (line=69)
          E: action (line=70)
            A: android:name(0x01010003)="android.intent.action.RU
N" (Raw: "android.intent.action.RUN")
          E: category (line=72)
            A: android:name(0x01010003)="android.intent.category.
DEFAULT" (Raw: "android.intent.category.DEFAULT")
        E: meta-data (line=75)
          A: android:name(0x01010003)="android.app.lib_name" (Raw
: "android.app.lib_name")
          A: android:value(0x01010024)="RetroEngine" (Raw: "Retro
Engine")
      E: provider (line=80)
        A: android:name(0x01010003)="androidx.startup.Initializat
ionProvider" (Raw: "androidx.startup.InitializationProvider")
        A: android:exported(0x01010010)=(type 0x12)0x0
        A: android:authorities(0x01010018)="org.rems.rsdkv5.andro
idx-startup" (Raw: "org.rems.rsdkv5.androidx-startup")
        E: meta-data (line=84)
          A: android:name(0x01010003)="androidx.emoji2.text.Emoji
CompatInitializer" (Raw: "androidx.emoji2.text.EmojiCompatInitial
izer")
          A: android:value(0x01010024)="androidx.startup" (Raw: "
androidx.startup")
        E: meta-data (line=87)
          A: android:name(0x01010003)="androidx.lifecycle.Process
LifecycleInitializer" (Raw: "androidx.lifecycle.ProcessLifecycleI
nitializer")
          A: android:value(0x01010024)="androidx.startup" (Raw: "
androidx.startup")
➜  Downloads cd apkdir
➜  apkdir apkedit b -i . -o app.apk
00.000 I: [BUILD] Using: APKEditor version 1.3.9, ARSCLib version
 1.3.5
      -t = xml
      -i = .
      -o = app.apk
 ________________
00.100 I: [BUILD] Scanning XML directory ...
00.202 I: [BUILD] Scanning: .
00.875 I: [BUILD] Initializing android framework ...
00.875 I: [BUILD] Loading android framework for version: 33
01.304 I: [BUILD] Initialized framework: android-33 (UpsideDownCa
ke)
01.305 I: [BUILD] Set main package id from manifest: @mipmap/ic_l
auncher
01.319 I: [BUILD] Main package id initialized: id = 0x7f, from: @
mipmap/ic_launcher
01.319 I: [BUILD] Encoding attrs ...
01.660 I: [BUILD] Encoding values ...
02.720 I: [BUILD] Scan: package_1/res
02.829 I: [BUILD] Scanned 360 files: package_1/res
02.942 I: [BUILD] Add manifest: AndroidManifest.xml
02.942 I: [BUILD] Building dex ...
03.314 I: [BUILD] (1/1) Cached: classes.dex
03.314 I: [BUILD] Scanning root directory ...
03.317 I: [BUILD] Restoring original file paths ...
03.367 I: [BUILD] Loading signatures ...
03.390 I: [BUILD] Sorting files ...
03.407 I: [BUILD] Refreshing resource table ...
03.446 I: [BUILD] TableBlock: packages = 1, size = 231452 bytes
03.447 I: [BUILD] Writing apk...
03.479 I: [BUILD] Buffering compress changed files ...
07.186 I: [BUILD] Writing files: 423
07.228 I: [BUILD] Writing signature block ...
07.248 I: [BUILD] Saved to: app.apk
➜  apkdir ls
AndroidManifest.xml  path-map.json  signatures
app.apk              resources      smali
archive-info.json    root           uncompressed-files.json
➜  apkdir aapt d xmltree *.apk AndroidManifest.xml
N: android=http://schemas.android.com/apk/res/android
  N: android=http://schemas.android.com/apk/res/android
    N: android=http://schemas.android.com/apk/res/android
      N: android=http://schemas.android.com/apk/res/android
        N: android=http://schemas.android.com/apk/res/android
          N: android=http://schemas.android.com/apk/res/android
            N: android=http://schemas.android.com/apk/res/android
              N: android=http://schemas.android.com/apk/res/andro
id
                N: android=http://schemas.android.com/apk/res/and
roid
                  N: android=http://schemas.android.com/apk/res/a
ndroid
                    N: android=http://schemas.android.com/apk/res
/android
                      N: android=http://schemas.android.com/apk/r
es/android
                        N: android=http://schemas.android.com/apk
/res/android
                          N: android=http://schemas.android.com/a
pk/res/android
                            N: android=http://schemas.android.com
/apk/res/android
                              E: manifest (line=9)
                                A: android:versionCode(0x0101021b
)=(type 0x10)0x64
                                A: android:versionName(0x0101021c
)="1.1.0" (Raw: "1.1.0")
                                A: android:installLocation(0x0101
02b7)=(type 0x10)0x0
                                A: android:compileSdkVersion(0x01
010572)=(type 0x10)0x21
                                A: android:compileSdkVersionCoden
ame(0x01010573)="13" (Raw: "13")
                                A: package="org.rems.rsdkv5" (Raw
: "org.rems.rsdkv5")
                                A: platformBuildVersionCode=(type
 0x10)0x21
                                A: platformBuildVersionName=(type
 0x10)0xd
                                E: uses-sdk (line=11)
                                  A: android:minSdkVersion(0x0101
020c)=(type 0x10)0x15
                                  A: android:targetSdkVersion(0x0
1010270)=(type 0x10)0x21
                                E: uses-feature (line=12)
                                  A: android:glEsVersion(0x010102
81)=(type 0x11)0x20000
                                E: uses-feature (line=14)
                                  A: android:name(0x01010003)="an
droid.hardware.touchscreen" (Raw: "android.hardware.touchscreen")
                                  A: android:required(0x0101028e)
=(type 0x12)0x0
                                E: uses-feature (line=16)
                                  A: android:name(0x01010003)="an
droid.hardware.bluetooth" (Raw: "android.hardware.bluetooth")
                                  A: android:required(0x0101028e)
=(type 0x12)0x0
                                E: uses-feature (line=18)
                                  A: android:name(0x01010003)="an
droid.hardware.gamepad" (Raw: "android.hardware.gamepad")
                                  A: android:required(0x0101028e)
=(type 0x12)0x0
                                E: uses-feature (line=20)
                                  A: android:name(0x01010003)="an
droid.hardware.usb.host" (Raw: "android.hardware.usb.host")
                                  A: android:required(0x0101028e)
=(type 0x12)0x0
                                E: uses-feature (line=22)
                                  A: android:name(0x01010003)="an
droid.hardware.type.pc" (Raw: "android.hardware.type.pc")
                                  A: android:required(0x0101028e)
=(type 0x12)0x0
                                E: uses-permission (line=24)
                                  A: android:name(0x01010003)="an
droid.permission.WRITE_EXTERNAL_STORAGE" (Raw: "android.permissio
n.WRITE_EXTERNAL_STORAGE")
                                  A: android:maxSdkVersion(0x0101
0271)=(type 0x10)0x1e
                                E: uses-permission (line=25)
                                  A: android:name(0x01010003)="an
droid.permission.MANAGE_EXTERNAL_STORAGE" (Raw: "android.permissi
on.MANAGE_EXTERNAL_STORAGE")
                                E: uses-permission (line=26)
                                  A: android:name(0x01010003)="an
droid.permission.READ_EXTERNAL_STORAGE" (Raw: "android.permission
.READ_EXTERNAL_STORAGE")
                                E: uses-permission (line=27)
                                  A: android:name(0x01010003)="an
droid.permission.BLUETOOTH" (Raw: "android.permission.BLUETOOTH")
                                E: permission (line=29)
                                  A: android:name(0x01010003)="or
g.rems.rsdkv5.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION" (Raw: "or
g.rems.rsdkv5.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION")
                                  A: android:protectionLevel(0x01
010009)=(type 0x11)0x2
                                E: uses-permission (line=30)
                                  A: android:name(0x01010003)="or
g.rems.rsdkv5.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION" (Raw: "or
g.rems.rsdkv5.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION")
                                N: android=http://schemas.android
.com/apk/res/android
                                  N: android=http://schemas.andro
id.com/apk/res/android
                                    N: android=http://schemas.and
roid.com/apk/res/android
                                      E: application (line=36)
                                        A: android:label(0x010100
01)=@0x7f0d001c
                                        A: android:icon(0x0101000
2)=@0x7f0c0000
                                        A: android:allowBackup(0x
01010280)=(type 0x12)0xffffffff
                                        A: android:hardwareAccele
rated(0x010102d3)=(type 0x12)0xffffffff
                                        A: android:extractNativeL
ibs(0x010104ea)=(type 0x12)0xffffffff
                                        A: android:appComponentFa
ctory(0x0101057a)="androidx.core.app.CoreComponentFactory" (Raw: 
"androidx.core.app.CoreComponentFactory")
                                        E: activity (line=41)
                                          A: android:theme(0x0101
0000)=@0x7f0e00fd
                                          A: android:label(0x0101
0001)=@0x7f0d001c
                                          A: android:icon(0x01010
002)=@0x7f0c0000
                                          A: android:name(0x01010
003)="org.rems.rsdkv5.Launcher" (Raw: "org.rems.rsdkv5.Launcher")
                                          A: android:exported(0x0
1010010)=(type 0x12)0xffffffff
                                          N: android=http://schem
as.android.com/apk/res/android
                                            N: android=http://sch
emas.android.com/apk/res/android
                                              E: intent-filter (l
ine=42)
                                                E: action (line=4
3)
                                                  A: android:name
(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.a
ction.MAIN")
                                                E: category (line
=44)
                                                  A: android:name
(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.in
tent.category.LAUNCHER")
                                        N: android=http://schemas
.android.com/apk/res/android
                                          E: activity (line=54)
                                            A: android:theme(0x01
010000)=@0x7f0e0005
                                            A: android:icon(0x010
10002)=@0x7f0c0000
                                            A: android:name(0x010
10003)="org.rems.rsdkv5.RSDK" (Raw: "org.rems.rsdkv5.RSDK")
                                            A: android:exported(0
x01010010)=(type 0x12)0xffffffff
                                            A: android:launchMode
(0x0101001d)=(type 0x10)0x3
                                            A: android:screenOrie
ntation(0x0101001e)=(type 0x10)0x6
                                            A: android:configChan
ges(0x0101001f)=(type 0x11)0x4a0
                                            A: android:alwaysReta
inTaskState(0x01010203)=(type 0x12)0xffffffff
                                            N: android=http://sch
emas.android.com/apk/res/android
                                              N: android=http://s
chemas.android.com/apk/res/android
                                                E: intent-filter 
(line=55)
                                                  E: action (line
=56)
                                                    A: android:na
me(0x01010003)="android.intent.action.RUN" (Raw: "android.intent.
action.RUN")
                                                  E: category (li
ne=57)
                                                    A: android:na
me(0x01010003)="android.intent.category.DEFAULT" (Raw: "android.i
ntent.category.DEFAULT")
                                            E: meta-data (line=60
)
                                              A: android:name(0x0
1010003)="android.app.lib_name" (Raw: "android.app.lib_name")
                                              A: android:value(0x
01010024)="RetroEngine" (Raw: "RetroEngine")
                                        N: android=http://schemas
.android.com/apk/res/android
                                          N: android=http://schem
as.android.com/apk/res/android
                                            E: provider (line=64)
                                              A: android:name(0x0
1010003)="androidx.startup.InitializationProvider" (Raw: "android
x.startup.InitializationProvider")
                                              A: android:exported
(0x01010010)=(type 0x12)0x0
                                              A: android:authorit
ies(0x01010018)="org.rems.rsdkv5.androidx-startup" (Raw: "org.rem
s.rsdkv5.androidx-startup")
                                              E: meta-data (line=
66)
                                                A: android:name(0
x01010003)="androidx.emoji2.text.EmojiCompatInitializer" (Raw: "a
ndroidx.emoji2.text.EmojiCompatInitializer")
                                                A: android:value(
0x01010024)="androidx.startup" (Raw: "androidx.startup")
                                              E: meta-data (line=
68)
                                                A: android:name(0
x01010003)="androidx.lifecycle.ProcessLifecycleInitializer" (Raw:
 "androidx.lifecycle.ProcessLifecycleInitializer")
                                                A: android:value(
0x01010024)="androidx.startup" (Raw: "androidx.startup")
➜  apkdir
REAndroid commented 1 month ago

I replicate this issue, it will be fixed soon. Thank you

REAndroid commented 1 month ago

Confirm 0582885 fixes this issue