julKali / makeDebuggable

A script to make a release Android APK debuggable
67 stars 9 forks source link

File header not of size 8! #3

Closed decodergit closed 2 years ago

decodergit commented 2 years ago

Hello! I try to make debuggable version of some release app with

apktool d -o output-dir com.app.apk
python3 makeDebuggable.py xml ./output-dir/AndroidManifest.xml ./output-dir/AndroidManifest.xml

But I have that error message

Traceback (most recent call last):
  File "***/makeDebuggable.py", line 606, in <module>
    patchManifestByFilename(sys.argv[2], sys.argv[3])
  File "***/makeDebuggable.py", line 528, in patchManifestByFilename
    patchManifest(fIn, tmp)
  File "***/makeDebuggable.py", line 463, in patchManifest
    raise Exception("File header not of size 8!")

And if I try

python3 makeDebuggable.py apk com.app.apk com.app_debuggable.apk resign.keystore alias_name

with key, generated with

keytool -genkey -v -keystore resign.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

I have output

Patching AndroidManifest.xml ...
Found application tag at 19892 !
Debuggable not present, need to update string pool, res map and attributes ...
Injecting 'debuggable' at index 47 ...
Copying rest of files
zipalign not found in path, aborting.

and file com.app_debuggable.apk.tmp with correct size. But I think, it's not signed.

Please say what are you thinking about it. Thanks a lot!

julKali commented 2 years ago

Hey there! The first approach doesn't work because apktool already decodes the xml file to human-readable code. This script, however, expects the binary format. If you only need to xml patched (a rare case), you can open the apk with a zip file viewer and extract the xml file directly from there without going through apktool. The apk command (which you seem to need) uses zipalign, which means you need to install it first on the machine you're using. Afaik, this comes by default with android build-tools, so it should be enough to just add the folder containing the zipalign binary to PATH.

decodergit commented 2 years ago

Great! Thanks a lot! It debuggable now. I have more problems with that app. But it is completely different problems😁