1940

I am using Eclipse Android plugins to build a project, but I am getting this error in the console window:

[2010-02-03 10:31:14 - androidVNC]Error generating final archive:
Debug certificate expired on 1/30/10 2:35 PM!

How do I fix it?

Damian Kozlak
  • 6,719
  • 10
  • 42
  • 50
hap497
  • 129,793
  • 42
  • 77
  • 91

17 Answers17

2256

Delete your debug certificate under ~/.android/debug.keystore on Linux and Mac OS X; the directory is something like %USERPROFILE%/.androidon Windows.

The Eclipse plugin should then generate a new certificate when you next try to build a debug package. You may need to clean and then build to generate the certificate.

Jorgesys
  • 114,263
  • 22
  • 306
  • 247
Christopher Orr
  • 106,059
  • 26
  • 192
  • 189
  • 13
    On Windows I had to delete the debug.keystore and make some changes to get a new compile going. I created a new test project, and the new debug.keystore was generated. – Tomas Jun 08 '10 at 13:37
  • 117
    It will also be re-generated for the current project if you 'clean' the project (go to Project -> Clean...) – adamnfish Jul 24 '10 at 17:50
  • 11
    There is now a bug tracker issue requesting this to be fixed. Please vote for it. http://code.google.com/p/android/issues/detail?id=15370 – Manfred Moser Mar 09 '11 at 19:52
  • 61
    Clean did not fix the problem for me, I needed to rm ~/.android/debug.keystore by hand. – James Moore May 02 '11 at 18:26
  • 3
    @James Deleting the keystore by hand is the first part of the answer above. Cleaning the project (or rebuilding) is what you need to do to generate a new keystore. – Christopher Orr May 03 '11 at 22:11
  • I don't like the idea of using 'clean', because the last time I did that, it deleted my R.java file and caused more problems. Just make some change to the code and save. That should force a rebuild. – SSZero Jun 06 '11 at 14:48
  • 3
    The directory location on Windows 7 is: C:\Users\[Username]\.android – Jason Jun 29 '11 at 15:07
  • 2
    @Manfred Moser - https://review.source.android.com/#/c/22128/ looks like the fix is in. Default will be a 30 year certificate. – MattK Jun 30 '11 at 01:53
  • On Vista and win7 this is here: %USERPROFILE%\.android – mhl666 Jul 04 '11 at 14:30
  • worked for me on mac/eclipse. You need to perform a clean before the error will be gone. No code modification needed then. – hcpl Oct 20 '11 at 13:51
  • yeah but you lose app data in either solutions of deleting the debug signature.. is there anyway of saving it? – Orkun Ozen Nov 03 '11 at 00:27
  • 1
    If you have root access to the device, you can just copy the important contents of the /data/data/ directory. – Christopher Orr Nov 05 '11 at 23:33
  • 1
    IMPORTANT: sravan below is correct that Mac hides files and folders that begin with a dot, just like Windows. To modify your settings so that you can see and delete the file in that hidden folder, follow the instructions here: http://guides.macrumors.com/Viewing_hidden_files_on_a_Mac – Melinda Green Mar 14 '12 at 23:35
  • Found this same issue with a build server running Team City and ant. The keystore was located at C:\.android\ Took me a while to find. – Oliver Apr 13 '12 at 16:42
  • For me (on Windows 7), it was enough to remove the file 'debug.keystore' from '%USERPROFILE%/.android' and then restart eclipse. – Yaniv Apr 29 '12 at 07:39
  • @SSZero When that happens, closing the project in the package explorer and opening it again usually does the trick for me. – DuneCat May 11 '12 at 14:00
  • Clean did not fix the problem for me, had to delete ~/.android folder manually – Tawani May 17 '12 at 20:11
  • 1
    Two years on, still working like a charm. Wish they'd fix this issue, or at least inform it when it occurs – Raveesh Bhalla Jun 19 '12 at 21:34
  • I formatted my pc and i lost my old debug.keystore. But now i want that same keystore. Any way to get the older debug.keystore ? – Bipin Vayalu Nov 20 '12 at 19:09
  • I had to restart Eclipse as well... (on Linux) – Chris Feb 18 '13 at 14:05
  • Is there a way to extend the certificate date without delete – hakiko Feb 26 '13 at 00:37
  • I came looking here after doing a console build and getting this error; in Eclipse I got only a popup that said, "There was an error(s) building this project, please fix the error and try again." but with no indication what the error was in any window that I could find. (I'm an Eclipse noob.) – dash-tom-bang May 04 '13 at 00:11
  • debug.keystore is in C:\Program Files (x86)\Android\android-sdk\.android in my case. But now it works ! – Alex R. Jun 02 '14 at 14:57
  • If you are shifting from Eclipse to android studio see this link http://stackoverflow.com/questions/27609442/how-to-get-the-sha1-fingerprint-certificate-in-android-studio-for-debug-mode/27639043#27639043 – Jamil Nov 02 '15 at 19:22
  • How can we detect which os in build.gradle file? – Tony Nov 24 '20 at 19:46
341

Upon installation, the Android SDK generates a debug signing certificate for you in a keystore called debug.keystore. The Eclipse plug-in uses this certificate to sign each application build that is generated.

Unfortunately a debug certificate is only valid for 365 days. To generate a new one you must delete the existing debug.keystore file. Its location is platform dependent - you can find it in Preferences - Android - Build - Default debug keystore.

D.J
  • 1,258
  • 10
  • 22
Jeff Gilfelt
  • 25,751
  • 7
  • 46
  • 47
259

It's a pain to have to delete all your development .apk files, because the new certificate doesn't match so you can't upgrade them in all your AVDs. You have to get another development MAP-API key as well. There's another solution.

You can create your own debug certificate in debug.keystore with whatever expiration you want. Do this in the .android folder under your HOME directory:

keytool -genkey -v -keystore debug.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -validity 14000

keytool.exe can be found in the JDK bin folder (e.g. C:\Program Files\Java\jdk1.6.0_31\bin\ on Windows).

ADT sets the first and last name on the certificate as "Android Debug", the organizational unit as "Android" and the two-letter country code as "US". You can leave the organization, city, and state values as "Unknown". This example uses a validity of 14000 days. You can use whatever value you like.

Deanna
  • 22,939
  • 7
  • 65
  • 142
Dave MacLean
  • 5,094
  • 1
  • 20
  • 30
  • 3
    I like this because it provides a more long-term fix until the SDK provides a better way to handle the expiring cert. – Sean Aitken Apr 05 '11 at 16:36
  • 23
    I like this because I don't need to use eclipse at all. – MattK Jun 30 '11 at 01:50
  • I'm assuming that this is to be typed under the command line. If so, I get a "keytool is not recognized" error. Can you further explain this method? – Ted Betz Nov 18 '11 at 19:17
  • 1
    keytool can be found in your JDK's bin directory (any OS). I usually add this bin directory to my PATH so the above would work from anywhere. You could either find your JDK bin directory and add it to your PATH, or you could put the full pathname to keytool on the command line. – Dave MacLean Nov 26 '11 at 20:55
  • 1
    As other commenters have pointed out, Google seems to have extended the default duration of the debug certificate so deleting the debug.keystore file and doing clean/build is much easier. – Dave MacLean Nov 26 '11 at 21:06
  • I'm doing a CI build using hudson, and this works where the eclipse answer doesn't. – nont Jan 03 '13 at 20:22
82

On Vista, this worked:

  1. DOS: del c:\user\dad\.android\debug.keystore

  2. ECLIPSE: In Project, Clean the project. Close Eclipse. Re-open Eclipse.

  3. ECLIPSE: Start the Emulator. Remove the Application from the emulator.

You are good to go.

I was pretty worried when I say that error, but I fixed it from reading here and playing around for 10 minutes.

sth
  • 200,334
  • 49
  • 262
  • 354
70
  • WINDOWS

Delete: debug.keystore located in C:\Documents and Settings\\[user]\.android, Clean and build your project.

  • Windows 7 go to C:\Users\[username]\.android and delete debug.keystore file.

Clean and build your project.

  • MAC

Delete your keystore located in ~/.android/debug.keystore Clean and build your project.

In all the options if you can´t get the new debug.keystore just restart eclipse.

Jorgesys
  • 114,263
  • 22
  • 306
  • 247
58

In Windows 7 it is at the path

C:\Users\[username]\.android
  • goto this path and remove debug.keystore
  • clean and build your project.
Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
AZ_
  • 35,659
  • 28
  • 152
  • 199
42

If a certificate expires in the middle of project debugging, you must do a manual uninstall:

Please execute adb uninstall <package_name> in a shell.

Solata
  • 1,254
  • 2
  • 26
  • 38
40

On a Mac, open the Terminal (current user's directory should open), cd ".android" ("ls" to validate debug.keystore is there). Finally "rm debug.keystore" to remove the file.

jorisw
  • 647
  • 1
  • 9
  • 14
Michael Biermann
  • 3,035
  • 23
  • 23
37

The Android SDK generates a "debug" signing certificate for you in a keystore called debug.keystore.The Eclipse plug-in uses this certificate to sign each application build that is generated.

Unfortunately a debug certificate is only valid for 365 days. To generate a new one, you must delete the existing debug.keystore file. Its location is platform dependent - you can find it in Preferences -> Android -> Build -> *Default debug keystore.

If you are using Windows, follow the steps below.

DOS: del c:\user\dad.android\debug.keystore

Eclipse: In Project, Clean the project. Close Eclipse. Re-open Eclipse.

Eclipse: Start the Emulator. Remove the Application from the emulator.

If you are using Linux or Mac, follow the steps below.

Manually delete debug.keystore from the .android folder.

You can find the .android folder like this: home/username/.android

Note: the default .android file will be hidden.

So click on the places menu. Under select home folder. Under click on view, under click show hidden files and then the .android folder will be visible.

Delete debug.keystore from the .android folder.

Then clean your project. Now Android will generate a new .android folder file.

Flexo
  • 82,006
  • 22
  • 174
  • 256
sravan
  • 4,959
  • 1
  • 28
  • 33
35

I had this problem couple of weeks ago. I first tried the troubleshooting on the Android developer site, but without luck. After that I reinstalled the Android SDK, which solved my problem.

Maurits Rijk
  • 9,175
  • 2
  • 31
  • 50
34

H-m-m-m. Interesting how so many people have had slightly different experiences with this. I remember the days when this was considered a sign that the software was not ready for release, and the team would actually fix it BEFORE users started seeing these problems:(

My own experience was just a little different. I had already tried Project>Clean, but still got the same build failure. Then I deleted the debug.keystore (under .android) just as the first answer said. Still got the same problem. Then I did a clean again, and wonder of wonders, it worked!

Now don't get me wrong, I am glad that I got it working thanks to the hints in this thread. But clearly clean isn't working right, and how did it find an expired key after I deleted the keystore??? Clearly something is wrong with Eclipse or the ADT -- not so sure which.

Matt J.
  • 349
  • 3
  • 2
  • Eclipse tends to cache files, so a clean/refresh is required sometimes to let it know that the file has changed on disk. – navjotk Apr 03 '12 at 15:08
34

On Ubuntu, this worked:

I went to home/username/.android and I renamed keystore.debug to keystoreold.debug. I then closed Eclipse, started Eclipse, and SDK created new certificate keystore.debug in that folder.

You then have to uninstall/reinstall apps you installed via USB Debugging or an unsigned APK ("unsigned" APK = signed with debug certificate).

FreewheelNat
  • 2,737
  • 1
  • 18
  • 12
15

For windows xp go to C:\Documents and Settings\%userprofile%\.android and delete debug.keystore file, restart the eclipse and now your project get build without error.

Example path:

C:\Documents and Settings\raja.ap\.android\

read-here-for-more.

Iamat8
  • 3,646
  • 8
  • 22
  • 29
raja
  • 2,233
  • 2
  • 20
  • 25
15

First close the eclipse then

Open CMD by Window Key + R or via Run as Admin

Follows the following step

del "%USERPROFILE%\.android\debug.keystore"
keytool -genkey -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android -keyalg RSA -validity 30000

after this restart eclipse.

Iamat8
  • 3,646
  • 8
  • 22
  • 29
14

In Windows debug.keystore file is localtes at C:\Users\%Username%\.android folder. This file is created when you install your android SDK and is valid only for a year. After this perod you will start getting this error Error getting final archive: Debug certificate expired on xx/xx/xxxx.

To remove this error simply delete the file and run the program again. In my Eclipse I have enabled Project->Build Automatically so it directly worked but in case you have disabled it you will need to clean the project Project->Clean.. select your project and press ok. Then you will need to build it manually. 3rd click on your project and select Build project.(Note - You will only see this option if you have diabled Build Automatically feature in your Projects Menu)

Aniket Thakur
  • 58,991
  • 35
  • 252
  • 267
8

After you install the Android SDK in Eclipse, it generates a debug signing certificate for you in a keystore called debug.keystore. The Eclipse plug-in uses this certificate to sign each application build that is generated.

Now, the problem with this debug certificate is that it is only valid for a year, or 365 days. If your Eclipse IDE uses an expired debug certificate, you will not be able to create and/or deploy an Android app.

To fix this problem all you need to do is delete the debug.keystore file.

  1. Go to Preferences
  2. Android
  3. Build
  4. Default debug keystore

There you should see the folder where the file is located. Simply delete that file and you are good to go.

For more info. you can visit

http://developer.android.com/tools/publishing/app-signing.html

IntelliJ Amiya
  • 70,230
  • 14
  • 154
  • 181
1

To fix this problem, simply delete the debug.keystore file.

The default storage location for AVDs is

In ~/.android/ on OS X and Linux.

In C:\Documents and Settings\.android\ on Windows XP

In C:\Users\.android\ on Windows Vista and Windows 7.

Also see this link, which can be helpful.

http://developer.android.com/tools/publishing/app-signing.html

Girish Patel
  • 1,220
  • 4
  • 16
  • 30