有时候需要将最新编译的APK更新到系统中,可是更新之后不起效,原来是签名惹的祸。
签名需要的工具是signapk.jar,由/platform/build/tools/signapk/编译产生,编译完成后在/out/host/linux-x86/framework/中可以找到。
另外的公钥私钥在platform.pk8 platform.x509.pem等签名文件位于platform/build/target/product/security/中。
命令如下:
java -jar signapk.jar platform.x509.pem platform.pk8 my-unsigned.apk my.apk
上面命令中,使用platform权限签名。当然还有其他的权限,在
build/target/product/security/目录下的README文件描述如下:
The following standard test keys are currently included:
testkey -- a generic key for packages that do not otherwise specify a key.
platform -- a test key for packages that are part of the core platform.
shared -- a test key for things that are shared in the home/contacts process.
media -- a test key for packages that are part of the media/download system.
These test keys are used strictly in development, and should never be assumed
to convey any sort of validity. When $BUILD_SECURE=true, the code should not
honor these keys in any context.
LOCAL_CERTIFICATE := platform
如果没有在Android.mk文件中找到该属性,那就默认用testkey来签名。
签过名的APK就可以使用
adb push my.apk /system/app/