Apktool icon indicating copy to clipboard operation
Apktool copied to clipboard

apk not installable after recompiling

Open DieselDriver opened this issue 6 years ago • 8 comments

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.

DieselDriver avatar Aug 25 '20 12:08 DieselDriver

Could you please provide the APK with this issue? Thanks.

giacomoferretti avatar Aug 25 '20 13:08 giacomoferretti

https://easyupload.io/0xp7ql

MD5: 4FDBDAF5932CE8F838C37003CD828908

DieselDriver avatar Aug 26 '20 06:08 DieselDriver

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

giacomoferretti avatar Aug 26 '20 19:08 giacomoferretti

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.

giacomoferretti avatar Aug 28 '20 12:08 giacomoferretti

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?

DieselDriver avatar Sep 08 '20 11:09 DieselDriver

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

giacomoferretti avatar Sep 08 '20 19:09 giacomoferretti

Thanks @giacomoferretti.

Looks like resolved as requiring zip-aligning.

iBotPeaches avatar Sep 13 '20 13:09 iBotPeaches

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

gleison1986CEO avatar Jun 21 '24 23:06 gleison1986CEO