One day I opened eclipse to start a new android application, after creating the project and trying to run it I received the following error:

[2010-08-27 15:32:04 – (Project Name)] Error generating final archive: Debug certificate expired on 7/30/10 10:42 PM!

After searching I found this link which suggests the solution:

The problem comes from the fact that Android required the applications to be signed even in the debug mode. So it uses a keystore file called debug.keystore to providde keys for signing applications in debug mode. This key store file has a validity period by default 365 days from its creation date.

The First Solution:

Navigate to the .android folder in your home directory “~/.android” (Linux,Mac OS) or c:\Documents and Settings\[User Name]\.android in windows XP or C:\Users\.android in windows Vista or Windows 7, and delete debug.keystore file. Then go to eclipse clean the project, this will create a new debug.keystore file with default validity period 365 days.

The Second Solution:

Create a new default.keystore file with custom validity period (say 1000 days).
  1. Navigate to the .android folder.
  2. Delete the old default.keystore file.
  3. We will use JDK Keytool.exe to generate the new key file. It is found in C:\Program Files\Java\jre6\bin in windows or inside the Java\jre6\bin folder in Mac OS or Linux.
  4. Open the terminal app in Mac OS or Linux or the command prompt and navigate to keytool.exe directory.
  5. Run the following command:
    keytool -genkey -keypass android -keystore debug.keystore -alias androiddebugkey -storepass android -validity 1000 -dname “CN=Android Debug,O=Android,C=US”
  6. This will generate a new default.keystore file with validity period 1000 days.
  7. Copy the generated file to the .android folder, go to eclipse and clean projects and it should work.
The above command has the following options:
  • genkey: generates a key pair.
  • keystore <Key Store Name>: the name of the key store file.
  • alias <alias name>: an alias for the key store. If the alias name is more than 8 characters the first 8 only are used.
  • storepass <password>: the password for the key.
  • validity <Validty Period>: the validity period for the key in days.
  • dname <name>: A Distinguished Name that describes who created the key. The value is used as the issuer and subject fields in the self-signed certificate.