Thứ Hai, 27 tháng 12, 2010

Android: Problem with "Debug Certificate expired on.."

This note is created for anybody who have the same issue like me when built an Android project by Eclipse and got "Error generating final archive: Debug certificate expired on !". It occurs to me when i tried to open and build a very old Android project. The reason for it happened is:
Android required the applications to be signed even in the debug mode. So it uses a keystore file called debug.keystore to provide keys for signing applications in debug mode. This key store file has a validity period by default 365 days from its creation date.
(From Android-pro)
And there have 2 ways to resolve this issue:
A. 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\[User Name]\.android"
in windows Vista or Windows 7,
then 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.
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
  4. Run the following command in the "cmd" (or terminate):
    keytool -genkey -keypass android -keystore debug.keystore -alias androiddebugkey -storepass android -validity 1000 -dname “CN=Android Debug,O=Android,C=US”
  5. This will generate a new default.keystore file with validity period 1000 days.
  6. Copy the generated file to the ".android" folder, go to eclipse and clean projects and it should work.
Good luck,