apktool -version) - 2.2.4The option that is not working is:
usage: apktool [-q|--quiet OR -v|--verbose] b[uild] [options] <app_path>
...
-d,--debug Sets android:debuggable to "true" in the APK's compiled manifest
...
When the option is specified in the apktool arguments, it is processed at:
apkOptions.debugMode = true;
This value is used at:
ResXmlPatcher.removeApplicationDebugTag(new File(appDir, "AndroidManifest.xml"));
This method is in fact removing the "android:debuggable" item from the AndroidMAnifest.xml file, rather than setting it to "true".
apktool d app.apkapktool b -d <app_dir>apktool d, apktool b without changing anything? YesSo, we remove the element yes, but thats because we apply the debuggable trait at the aapt level. If you leave the property in, aapt fails. So we strip it out in debug mode, so that we know aapt can properly add.
I'm not sure if you discovered this in a code audit, but I tested with an actual application and could not replicate this.
I did a simple decode/build to test this and it worked.
➜ dist aapt d xmltree app-debug.apk AndroidManifest.xml
E: application (line=3)
A: android:theme(0x01010000)=@0x7f0900a6
A: android:label(0x01010001)=@0x7f070022
A: android:icon(0x01010002)=@0x7f030000
A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
Closing as I couldn't duplicate. Thanks for the detailed report, makes my life a lot easier when digging into tickets.
You can see the line responsible here - https://github.com/iBotPeaches/Apktool/blob/master/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java#L365
Hi @iBotPeaches:
I have been able to reproduce this issue based on your explanation. The debuggable flags is not added when the APK is decoded first with the "-r" flag, as the resources are not decoded and, therefore, "aapt" cannot add the flag during the build process.
I think it would be very useful to be able to use the "-d" flag during the build process even when the "-r" (and "-s") flags are used during the decoding process, with the goal of minimizing the changes performed over the APK.
I was originally expecting this, assuming that apktool was simply and directly modifying the AndroidManifest.xml file, rather than using "aapt".
Do you think this could be considered as a potential future request for apktool to be able to run "apktool d -r -s app.apk" and "apktool b -d
@raulsiles @iBotPeaches this would be just what I am looking for. For some reason repackaging without -r fails
after I use Apktool v2.2.1 When change manifest and add android:debuggable="true" and build again, the manifest not change? why
1.apktool d main.apk
2.change manifest and add android:debuggable="true"
3.apktool b main
Most helpful comment
Hi @iBotPeaches:
I have been able to reproduce this issue based on your explanation. The debuggable flags is not added when the APK is decoded first with the "-r" flag, as the resources are not decoded and, therefore, "aapt" cannot add the flag during the build process.
I think it would be very useful to be able to use the "-d" flag during the build process even when the "-r" (and "-s") flags are used during the decoding process, with the goal of minimizing the changes performed over the APK.
I was originally expecting this, assuming that apktool was simply and directly modifying the AndroidManifest.xml file, rather than using "aapt".
Do you think this could be considered as a potential future request for apktool to be able to run "apktool d -r -s app.apk" and "apktool b -d"?