Home » How to re-sign a Android apk file for testing

How to re-sign a Android apk file for testing

In the last days I got some questions about how to resign the apk file you want to test. And here is the answer. First some basic about the signatures in Android development! A signature is needed to identify the author of the Android application. A signature mostly contains information like:

  • First name
  • Last name
  • Name of the organization
  • City
  • State
  • Country Code

For more information please have a look at the Android SDK developer guide http://developer.android.com/guide/publishing/app-signing.html

If you want to test an apk file e.g. with Robotium the android app apk and your test project apk file MUST have the same signature!

There are two possible cases how to sign the apk file. The first one is really simple, if you build the Android app you want to test on your own within eclipse you don’t need to resign the apk file. The signatures should be the same. The second case is more complex.
If you get the apk file you have to test e.g. from your developers, from jenkins or from the market you have to resign the app. Do the following steps to resign it with your keystore:

  1. Rename the apk file into a zip file, e.g. Name.apk = Name.zip
  2. Unpack/ Unzip the zip file
  3. Delete the META-INF folder
  4. Repack/ Rezip the folder again to a zip file
  5. Rename the zip file again to an apk file
  6. Open a terminal window / Command prompt and enter (the jarsigner tool is located in the bin folder of your installed java sdk

jarsigner -keystore ~/.android/debug.keystore -storepass android -keypass
android APPNAME.apk androiddebugkey

That’s it! Afterwards you should be able to test against an apk file!

Have fun!