Tuesday, February 3, 2015

"INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES", sign application with AOSP sign keys

One of my application was built within the AOSP Android platform. But I need to build that in Eclipse Android ADT and test that app separately on Android. While I was trying to debug that app on my phone using eclipse, I got that error "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES". I know it could be the problem of the signing key, but how could I use the same one that was used in AOSP?

I referred to:

  • http://stackoverflow.com/questions/3635101/how-to-sign-android-app-with-system-signature
  • http://stackoverflow.com/questions/4247818/android-after-building-platform-source-how-to-sign-arbitrary-apk-with-platform
  • http://stackoverflow.com/questions/15754060/how-to-set-a-custom-keystore-for-debugging-in-eclipse-for-android
And I finally know how to do that.
  1. Locate the pk8 and cert files in AOSP project
    It's under the folder AOSP_PATH/build/target/product/security
  2. Download and install keytool-importkeypair from https://github.com/getfatday/keytool-importkeypair
  3. Make the keystore: keytool-importkeypair [-k keystore] [-p storepass] -pk8 pk8 -cert cert -alias key_alias
    Remember that the key_alias for Eclipse default debug key is androiddebugkey
  4. Setup eclipse to use the customized keystore
    Go to "Window->Preference->Android->Build" and set the Custome debug keystore to the one we just generated.
  5. Rebuild the app and now it should work.

No comments:

Post a Comment