Claudio Ferraro
Claudio Ferraro

Reputation: 4721

Can't recompile working APK with APKtool

I decompiled an APK using APKTool 2.0 Beta 9 and then rebuilt all without doing changes to the sources. Then I rebuilt the APK using this command:

java -jar apktool.jar build myfolder myapk.apk

But I cannot install the generated APK file on my phone. It tells me:

Application not installed.

Am I missing something ? I even didn't change the code.

Upvotes: 4

Views: 5209

Answers (2)

node_analyser
node_analyser

Reputation: 1612

Your new recompiled apk is not signed and according to the rules, you cannot install unsigned apk.

One good thing which I like is that you can self sign the apk file.

You will have to use "Keytool" for generating your own certificate.

Here is the command :

keytool –genkey –v -keystore [nameofkeystore] –alias [your_keyalias] –keyalg RSA –keysize 2048 –validity [numberofdays]

This will ask you few things, just fill it appropriately.

Once the certificate is generated, use "jarsigner" for signing your apk.

jarsigner –verbose –sigalg MD5withRSA –digestalg SHA1 –keystore [name of your keystore] [your .apk file] [your keyalias]

Now try installing your new apk file and everything should work fine.

EDIT - I am using keytool and jarsigner commands directly as I have set their paths in PATH variable. In your case, you will have to traverse to "bin" folder of the jdk directory. /bin/

Upvotes: 7

Prateek
Prateek

Reputation: 1

You need to resign the regenerated APK file using jarsigner:

$ jarsigner -verbose -keystore my-release-key.keystore HelloWorld.apk alias_name

Upvotes: 0

Related Questions