给系统apk签名
1.使用platform密钥对apk进行签名
1.1.进入<Android_Source_Path>/build/target/product/security,找到【platform.pk8】和【platform.x509.pem】系统密钥。
1.2.进入<Android_Source_Path>/build/tools/signapk找到SignApk.java,运行javac编译成SignApk.class
1.3.执行命令java com.android.signapk.SignApk platform.x509.pem platform.pk8 input.apk output.apk至此,完成。
2. 对1的补充:
<Android_Source_Path>/build/target/product/security下有多对密钥,详细如下:
Thefollowingcommandswereusedtogeneratethetestkeypairs:
development/tools/make_keytestkey'/C=US/ST=California/L=MountainView/O=Android/OU=Android/CN=Android/[email protected]'
development/tools/make_keyplatform'/C=US/ST=California/L=MountainView/O=Android/OU=Android/CN=Android/[email protected]'
development/tools/make_keyshared'/C=US/ST=California/L=MountainView/O=Android/OU=Android/CN=Android/[email protected]'
development/tools/make_keymedia'/C=US/ST=California/L=MountainView/O=Android/OU=Android/CN=Android/[email protected]'
Thefollowingstandardtestkeysarecurrentlyincluded:
testkey--agenerickeyforpackagesthatdonototherwisespecifyakey.
platform--atestkeyforpackagesthatarepartofthecoreplatform.
shared--atestkeyforthingsthataresharedinthehome/contactsprocess.
media--atestkeyforpackagesthatarepartofthemedia/downloadsystem.
Thesetestkeysareusedstrictlyindevelopment,andshouldneverbeassumed
toconveyanysortofvalidity.When$BUILD_SECURE=true,thecodeshouldnot
honorthesekeysinanycontext.
signingusingtheopensslcommandline(forboot/systemimages)
--------------------------------------------------------------
1.convertpk8formatkeytopemformat
%opensslpkcs8-informDER-nocrypt-intestkey.pk8-outtestkey.pem
2.createasignatureusingthepemformatkey
%openssldgst-binary-sha1-signtestkey.pemFILE>FILE.sig
extractingpublickeysforembedding
------------------------------------
it'saJavatool
butitgeneratesCcode
takealookatcommands/recovery/Android.mk
you'll see it running $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar3.对3的补充:
在运行第三步的命令前,请在你当前的工作目录下新建如下结构的文件夹:com.android.signapk,然后将第二步编译生成的SignApk放入该目录下。或者也可以将SignApk.java的package声明删除后再运行javac编译。
命令java com.android.signapk.SignApk platform.x509.pem platform.pk8 input.apk output.apk
不单可以对apk文件进行重签名,也可以对所有的zip文件进行重签名,包括ROM文件。
milestone的CM7相应文件地址为:https://github.com/nadlabak/android_build/tree/gingerbread/tools/signapk
相关推荐
adb shell cd system/app rm *.apk21. 获取管理员权限: adb root22. 启动Activity: adb shell am start -n 包名/包名+类名。