apk not installable after recompiling
Hello,
I tried to decompile and recompile an application.
After Recompiling it is not possible to install the application (except on NOX emulator with Android 5). But on all other emulators or tablets it is not possible to install the application. I tried it with aptool 2.40 and 2.41.
apktool d -r myApp.apk I: Using Apktool 2.4.1 on myApp.apk I: Copying raw resources... I: Baksmaling classes.dex... I: Baksmaling classes2.dex... I: Copying assets and libs... I: Copying unknown files... I: Copying original files... I: Copying META-INF/services directory
apktool b -o myApp_recompiled.apk ./myApp I: Using Apktool 2.4.1 I: Checking whether sources has changed... I: Smaling smali folder into classes.dex... I: Checking whether sources has changed... I: Smaling smali_classes2 folder into classes2.dex... I: Checking whether resources has changed... I: Copying raw resources... I: Copying libs... (/lib) I: Copying libs... (/kotlin) I: Copying libs... (/META-INF/services) I: Building apk file... I: Copying unknown files/dir... I: Built apk... user@PC:~/$
Thanks.
Could you please provide the APK with this issue? Thanks.
https://easyupload.io/0xp7ql
MD5: 4FDBDAF5932CE8F838C37003CD828908
Did you sign the APK after rebuilding?
Logcat installing the signed APK:
E NativeLibraryHelper: Library 'libgdx.so' is not page-aligned - will not be able to open it directly from apk.
W NativeHelper: Failure copying native libraries [errorCode=-2]
E PackageInstallerSession: Commit of session 127192669 failed: Failed to extract native libraries, res=-2
I think there is already an issue talking about this.
EDIT: Maybe duplicate of #1626
After rebuilding, try to zipalign it using this command: zipalign -p -f 4 input.apk output.apk
Then sign it with apksigner and you're done. It should work now.
Thanks, now it works.
Is there any general tool which can analyze the original apk file that I know if I have to use zipalign after recompiling?
With extractNativeLibraries set to false you must zipalign the APK after rebuilding it.
I think it's necessary to use the -p option with natives libraries. Correct me if I'm wrong.
You can read more about it here: https://developer.android.com/studio/command-line/zipalign
Thanks @giacomoferretti.
Looks like resolved as requiring zip-aligning.
WAY TO SIGN APPS RECOMPILED
- sudo apt -y install zipalign
- zipalign -p -f 4 input.apk output.apk
- keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA \ -keysize 2048 -validity 10000 -alias upload
- jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.jks my_application.apk alias_name AND DONE