Signing an existing apk using debug.keystore generated by eclipse

27,711

Solution 1

You don't really want to create it with your debug key, but;

-alias androiddebugkey 
-keystore /the/path/debug.keystore 
-storepass android 
-keypass android

Solution 2

jarsigner -verbose -keystore ~/.android/debug.keystore -storepass android -keypass android path/to/my.apk androiddebugkey

This worked for me.

Solution 3

For me, I have create a debug keystore first with all passwords, alias... are 'android' then go to Preferences -> Android -> Build and enter that as Custom debug keystore. Now any my debug will be auto signed with that key without requiring me to do any extra work!

Warning: I have learnt hard from my mistakes. I have uploaded my APK with that debug keystore to Google Store then published it for alpha testing (to test purchasing, signing in Google game play...). First that was very convenience since I could compile and run my app in debug mode without being trouble to re-enter keystore, passwords, create apk, install it on devices...

However, the problem is that after testing, I cannot upload the released apk (with my official keystore) to that project (because it has different key than previous loaded ones). I cannot delete that project either (since it has been published). At the end, I have to keep that one, rename the package of the app, create a new project, update new Google Api id, upload new apk... for official releasing.

Solution 4

Expiry of the Debug Certificate The self-signed certificate used to sign your application in debug mode has an expiration date of 365 days from its creation date. When the certificate expires, you will get a build error.

Share:
27,711

Related videos on Youtube

Dmitry Guselnikov
Author by

Dmitry Guselnikov

Java/Kotlin Android developer

Updated on July 09, 2022

Comments

  • Dmitry Guselnikov
    Dmitry Guselnikov almost 2 years

    I have an existing unsigned apk and I want to sign it using my debug.keystore file. Here I found a tutorial how it can be done.

    jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore my_application.apk alias_name
    

    But what should I write as alias_name and what should be the passphrase? Is there any way to find out what alias_name and passphrase are used by Eclipse during the signing?

    • stinepike
      stinepike about 11 years
      why do you want to sign using debug keystore.. why don't you create a new oe?
    • Dmitry Guselnikov
      Dmitry Guselnikov about 11 years
      Yeah, I know I can generate a new one, my purpouse is ability to update application which was build with the same debug.keystore instead of uninstalling
  • Dunc
    Dunc about 10 years
    FYI on Windows, the keystore is in %HOMEPATH%\.android\debug.keystore
  • StephenD
    StephenD almost 10 years
    -alias doesn't seem to be an option. The command line on Mac is: jarsigner -verbose -keystore ~/.android/debug.keystore -storepass android -keypass android path/to/my.apk androiddebugkey
  • Cory Trese
    Cory Trese over 8 years
    It is worth noting that jdk1.6 will successfully sign APK using this method, but jdk1.7.0 will not.
  • Roy Falk
    Roy Falk over 7 years
    JDK 8 will work with the invocation in the comment by StephenD.
  • Silas S. Brown
    Silas S. Brown over 4 years
    I have a debug.keystore generated in June 2013 that still works for me in 2020, so I guess the 365-day expiration date you found must have been added by a version of the SDK that came out after 2013.
  • Silas S. Brown
    Silas S. Brown over 4 years
    Incidentally, the newer Android Studio documentation says "The self-signed certificate used to sign your app for debugging has an expiration date of 30 years from its creation date" [emphasis mine]. So I don't know which versions set it to 365 days.