Wednesday, October 27, 2010

Removing signatures from ANDROID Application and make changes to it and finally resigning it... decompile and recompile.












The .apk application i.e, the compiled android applications will not be installed by Android until it has got some signatures.

You may get "INSTALL_PARSE_FAILED_NO_CERTIFICATES" error while using "adb install your_file.apk" command if your application is not signed.
Signatures are actually to protect the application from piracy, if you make any changes to .apk application's content directly then the signatures are lost (even if you make changes in the resources).
  
Now how to make changes to an existing .apk:
1> Open your target .apk application with winzip or winrar.
2> Delete the META-INF folder.
3>Now you may use "apktool" to decompile your .apk. Its a good tool which has inbuilt smali and baksmali.
you can download "apktool" from http://code.google.com/p/android-apktool/
4>Now decompile .apk with apktool using command "apktool d address_to_apk_file\myfile.apk  destination_folder_location".
5>Now you will be able to make all the changes you want. You can edit the .xml files and smali files to make changes to your application.
6>Now after that you may recompile your application with apktool using 'b' instead of 'd'.If you write apktool and press enter you will get help for using apktool.
7>BUT THIS IS NOT THE END......................
You still have to sign your applicaton.
You can do this with jarsigner which you will find in jdk's bin folder.

8>First find the .android directory in which you will find debug.keystore, generally you will find it here... 
C:\Documents and Settings\\Local Settings\Application Data\Android\
If you are using latest windows like window7 or window vista the "documents and settings" folder may be protected and you may not have the access.
So, first change the permissions.

9>ok...now copy the debug.keystore and paste in the bin folder of your jdk where you also have the jarsigner.
10>Also copy your target .apk to this folder for comfort.
11> NOW run the following command to finally sign your .apk:

ADDRESS_JDK\bin\jarsigner.exe -verbose -storepass android -keystore debug.keystore target.apk androiddebugkey


replace target.apk with your own unsigned apk.

12>If all goes right your application is ready to be installed on ANDROID.

NOTE: PLEASE don't use this for piracy. Its just for your help to change your already compiled .apk applications.