androidapkapktoolapksigner

Missing AndroidManifest.xml


So I wanted to replace one file in an application, and the way I did it is apktool d CATGAME.apk, which decompiles the .apk.

Then I replaced the one file I need, and do apktool b CATGAME to compile it. Then I zip align the file by running mv CATGAME.apk CATGAME-prealigned.apk; zipalign -v 4 CATGAME-prealigned.apk CATGAME.apk

After which, I do apksigner sign --ks ../ks.jks --v2-signing-enabled true --v3-signing-enabled true --min-sdk-version 29 CATGAME.apk(ks.jks in the parent directory is they keystore)

And to verify I run apksigner verify CATGAME.apk but the output is Exception in thread "main" com.android.apksig.apk.ApkFormatException: Missing AndroidManifest.xml at com.android.apksig.ApkSigner.getAndroidManifestFromApk(ApkSigner.java:970) at com.android.apksig.ApkVerifier.getAndroidManifestFromApk(ApkVerifier.java:1225) at com.android.apksig.ApkVerifier.verifyAndGetMinSdkVersion(ApkVerifier.java:640) at com.android.apksig.ApkVerifier.verify(ApkVerifier.java:196) at com.android.apksig.ApkVerifier.verify(ApkVerifier.java:164) at com.android.apksigner.ApkSignerTool.verify(ApkSignerTool.java:587) at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:95)

After extracting CATGAME.apk I see that now it became two folders META-INF and CATGAME

META-INF contains ALIAS_NA.RSA, ALIAS_NA.SF and MANIFEST.MF, while CATGAME contains normal things that would be in a normal apk.

I'm trying to make a tool to automate the process of replacing that file so a GUI tool probably won't work.

UPDATE: You just have to add --append-signature, it took me too long to find out


Solution

  • The solution was easy as adding --append-signature Sorry for wasting your time, I don't know how I didn't think of that