Android: After building platform source, how to sign arbitrary APK with platform key?

android, android-ndk

Solution

If you have your platform key/certificate pair (.pk8 + x509.pem). Which can be found under build/target/product/security in the pulbic sdk.

You can use the SignApk.jar from the command line

java -jar SignApk.jar platform.x509.pem platform.pk8 Application.apk Application_signed.apk

Or to make automation easier, you can import the key/cert pair into your java keystore file, with the keytool-importkeypair, and use an ant makefile or eclipse for signing.

keytool-importkeypair -k ~/.android/debug.keystore -p android -pk8 platform.pk8 -cert platform.x509.pem -alias platform

Problem

As an experiment, I would like to use the platform key of my custom built Android platform to sign an arbitrary APK, that is built via the NDK. What is the process to go about doing this?

Original source