49
votes

I have finally created a 'final' keystore for my app. As my app is using Google Maps, I take I have to update all Layouts to use the new API Key resulting from the app as well..

Now I'm fully aware of the requirement to export a signed APK for release, but what after that? My thoughts are that for further development and testing, it would be easiest if I could configure Eclipse to use my final keystore instead of the debug keystore … but I found no way to do that? It only allows me to configure an 'alternative' debug key but I guess that's not the same.

Sorry if I am too confused if I have totally misunderstood something here.

7
FYI, if you need to debug with your release keystore, add android:debuggable="true" to your <application> in your AndroidManifest.xml and then export the signed APK. Run the app on the device and you should be able to attach to your process and hit break points.Sam Dozor

7 Answers

62
votes

I was able to to use my Google Play release keystore as my custom debug keystore to help with debugging in-app purchase functionality. The same could no doubt be applied to debugging Google Maps stuff as well.

As Devunwired mentioned, there are caveats. But my solution was this:

  1. Copy your release key somewhere.
  2. Change the keystore password/key password and key alias following the instructions here (also, following Devunwired's recommendations to make it look like a debug keystore).
  3. Change Eclipse's Preferences > Android > Build > Custom keystore setting to the path of the copy made in step 1.
  4. Done!
71
votes

You can configure a custom keystore to use for your debug builds (the ones that happen when you click Run...) in Eclipse by going to Preferences -> Android -> Build and entering the file name in the "Custom debug keystore" option.

However, it has the caveat that it must follow the same rules as a traditional debug keystore, mainly:

  1. The keystore password must be "android"
  2. It must contain a key named "androiddebugkey"
  3. That key's password must be "android"

Therefore, while it is possible to sign your apps in debug with the same keystore as you Export with, it requires your production keystore to look like a debug store, which makes it less secure if someone got ahold if the file (it would be easier to inspect and guess the passwords).

HTH

4
votes

In order for Eclipse to sign automatically for you when you deploy you need to set up a keystore which behaves like the debug keystore. This means there must be an 'androiddebugkey' and both the key and keystore password must be 'android'. Therefore, I'd recommend the following:

  1. Make a copy of your keystore, I copied mine to a file called iap.keystore
  2. Open terminal/command window with keytool on the path (for me the path is D:\NVPACK\jdk1.6.0_45\bin\keytool.exe) or use the fullpath to keystore in the commands below
  3. Change your keystore password to 'android':
    • keytool -storepasswd -keystore iap.keystore
    • Follow prompt to enter your old keystore password
    • Follow prompt to enter android as the new password
    • Follow prompt to confirm android as the password
  4. Rename your key to androiddebugkey (replace Old_Key_Store_Name with your current key name in the next command)
    • keytool -changealias -keystore iap.keystore -alias Old_Key_Store_Name -destalias androiddebugkey
    • Follow prompt to enter your keystore password (which is now andorid)
    • Follow prompt to enter your Old_Key_Store_Name password (this is whatever you previously had your key password set to)
  5. Change the password for your androiddebugkey
    • keytool -keypasswd -keystore iap.keystore -alias androiddebugkey
    • Follow prompt to enter your keystore password (which is now andorid)
    • Follow prompt to enter your androiddebugkey password (this is whatever you previously had your key password set to)
    • Follow prompt to enter android as the new key password
    • Follow prompt to confirm android as the key password
  6. You now have a keystore (with key) which Eclipse can use to automatically sign builders.
  7. Load up Eclipse.
  8. Window -> Preferences -> Android -> Build
  9. Follow 'Custom debug keystore' browse to the iap.keystore file we previous created
  10. OK

Now when you launch/debug your project, it'll use the keystore we just set up to sign your project. This will allow things like IAP to work.

BEWARE: this is convenient, but of course if someone gets hold of your iap.keystore they will be able to sign things as you by using 'android' as the keystore/key password. Hopefully this is obviously from the steps listed above, but just take a second to appreciate what this means for yourself (or your company). Then based on that decide if the risks are acceptable, and if you need to carry out any extra measures to ensure the safety of this file.

3
votes

We set custom keystore to use for our debug builds. Eclipse Go to Preferences -> Android -> Build and ent the file name in the "Custom debug keystore".

Important when we create our keystore for eclipse customs.:

The keystore password must be "android" It must contain a key named "androiddebugkey" That key's password must be "android" Therefore, while it is possible to sign your apps in debug with the same keystore as you Export with, it requires your production keystore to look like a debug store, which makes it less secure if someone got ahold if the file (it would be easier to inspect and guess the passwords).

if we want to change the keystore password: $ keytool -storepasswd -keystore my.keystore

if we want to change the keystore alias password: $ keytool -keypasswd -keystore my.keystore -alias my_name

if we want to change the keystore alias: $ keytool -changealias -keystore my.keystore -alias my_name -destalias my_new_name

Vkj enter image description here

0
votes

Here there are the instructions to convert a regular keystore in a debug keystore: https://stackoverflow.com/a/15754187/917362

0
votes

You can enter both your debug and your release SHA1 for the same Google API key using the Google Developers Console (console.developers.google.com).

This way, you will have the same API key for both and will no longer have to change it in the AndroidManifest.xml.

0
votes

We have the same problem some time ago at our office. Since we needed this quite often we wrote a simple script to make it easy to to convert release keystores to debug ones.

The script is available on https://github.com/IntellexApps/key2debug

We are using it for some time now, so should be quite stable.

cheers!