8

I have created a modded apk using apktool but when I try to install it , it doesn't install. When I rechecked and compared it with an older apk I found out that my apk file wasn't signed. I searched a lot but couldn't find out a method to sign apk on mac OS X. Please help

Nitz
  • 45
  • 9
Mayur
  • 392
  • 1
  • 3
  • 12
  • [This documentation](http://developer.android.com/tools/publishing/app-signing.html) should provide you the information about signing your APK in both Android Studio and ADT for Eclipse. – ztan Nov 10 '14 at 17:39
  • thanks ztan your link helped. I have posted the solution below – Mayur Nov 12 '14 at 06:42

3 Answers3

16

Got my solution- I use keytool, Jarsigner and zipalign from JDK by using following commands in terminal

To generate keystore

keytool -genkey -v -keystore my-keystore.keystore -alias name_alias -keyalg RSA -validity 10000

To sign an apk

jarsigner -verbose -keystore <path of my-keystore.keystore> <path of apk>  name_alias

To zip align an apk

zipalign -f -v 4 <your.apk >  <your_aligned.apk>
RichardC
  • 794
  • 4
  • 13
Mayur
  • 392
  • 1
  • 3
  • 12
  • can you clarify what your.apk and your_aligned.apk are? I have an app-debug.apk and an app-release-unsigned.apk after the first two steps, but which one is which in step 3? – Nunchucks May 25 '18 at 23:20
  • if you are having an unsigned apk then you can start at step 2 if you already generated a keystore. In my case your.apk was a signed apk and your_aligned.apk was a zip aligned format. – Mayur May 27 '18 at 20:30
  • Ok, I had a misunderstanding. I'll add the note that would have been helpful to me here in case anyone else has the same confusion. is the file that the zipalign tool outputs and you can name it whatever you'd like. – Nunchucks May 29 '18 at 18:29
6

MacBook User.

1.You need to create .keystore file in terminal. Put on Folder the .Keystore and Your .Apk

keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -validity 10000

-Its ok to change alias_name and my-release-key but not .keystore

2.Put this on Terminal.

jarsigner -verbose -keystore <your .keystore> space <your app file> space <your alias name on creating keystore>

then ask you Enter Password put your password in created keystore . Now you have signed apk.

Note: you have JDK Install on your MacBook.

Shema Israel
  • 61
  • 1
  • 2
3

If the apk file is already signed, remove the original sign with following code

Zip -d <path of apk> META-INF/*

To sign an apk

jarsigner -verbose -keystore <path of my-keystore.keystore> <path of apk>  alias_name

To sign an apk not work and idk >=1.7

jarsigner -verbose  -digestalg SHA1 -sigalg MD5withRSA -keystore <path of my-keystore.keystore> <path of apk>  alias_name

To zip align an apk

 ~/Library/Android/sdk/build-tools/xxxxx/zipalign -f -v 4 <your.apk >  <your_aligned.apk>
Kit
  • 2,370
  • 13
  • 11