不同与android开发状态下编译系统过程,android系统开发中我们编译的是带debug调试信息的版本,既userdebug版本,生成步骤:
make clean
. build/envsetup.sh
lunch x
x是我们选择要编译的平台,就是lunch后
~/work/Android$ lunch
You're building on Linux
Lunch menu... pick a combo:
1. aosp_arm-eng
2. aosp_x86-eng
3. aosp_mips-eng
4. vbox_x86-eng
5. aosp_manta-userdebug
6. aosp_hammerhead-userdebug
7. aosp_mako-userdebug
8. aosp_deb-userdebug
9. aosp_tilapia-userdebug
10. aosp_flo-userdebug
11. aosp_grouper-userdebug
12. mini_armv7a_neon-userdebug
13. mini_mips-userdebug
14. mini_x86-userdebug
Which would you like? [aosp_arm-eng]
所对应的选项号。接着就是编译
make 或者 make -j4
编译后生成的目标文件会放在out/target/product/(对应的产品代号名)/下
release版的编译过程:
make clean
. build/envsetup.shmake -j4 PRODUCT-aosp_hammerhead-user dist
在out/目录下生成dist目录,build所生成的目标文件就在out/dist/下
adb aosp_hammerhead-img-eng.zhongjun.zip build.prop mkbootfs ramdisk.img
android-info.txt aosp_hammerhead-ota-eng.zhongjun.zip fastboot mkbootimg signapk.jar
aosp_hammerhead-apps-eng.zhongjun.zip aosp_hammerhead-symbols-eng.zhongjun.zip gpl_source.tgz mkyaffs2image vendor_owner_info.txt
aosp_hammerhead-emulator-eng.zhongjun.zip aosp_hammerhead-target_files-eng.zhongjun.zip installed-files.txt package-stats.txt
烧录:
~/work/Android.01/out/dist$ sudo chmod a+s fastboot
~/work/Android.01/out/dist$ ./fastboot update aosp_hammerhead-img-eng.xxsomeonexx.zip
如果要用vendor的release key重新签名
~/work/Android.01/out/dist$ ./build/tools/releasetools/sign_target_files_apks -d vendor/Modul/security/product_modul/ out/dist/product_modul-target_files.zip out/dist/signed_target_files.zip
ERROR: no key specified for:
CalendarWidget.apk
Contacts_yellowpage.apk
SnsAppMain.apk
fbandroid-1.5.0.apk
AnalogClockWidget.apk
MessageWidget.apk
NewsWidget.apk
上面的意思是使用sign_target_files_apks工具采用vendor/Modul/security/product_modul/下的key对product_modul-target_files.zip文件进行签名,并把签名结果放在out/dist/signed_target_files.zip里.
从上面的签名结果看,签名并没有成功,原因是由于有些apk程序已经签过名了或者找不到对应的key. 这也难不倒我们,我们可以通过设置过滤,不对上面的程序进行签名.方法如下:
通过参数"-e <apkname>=" 来过滤这些程序.
~/work/Android.01/out/dist$./build/tools/releasetools/sign_target_files_apks -dvendor/Modul/security/product_modul/ -e CalendarWidget.apk= -e Contacts_yellowpage.apk= -e SnsAppMain.apk= -e fbandroid-1.5.0.apk= -e AnalogClockWidget.apk= -e MessageWidget.apk= -e NewsWidget.apk= out/dist/product_modul-target_files.zip out/dist/signed_target_files.zip
Enter password for vendor/Modul/security/product_modul//media key> <----- imput the password
Enter password for vendor/Modul/security/product_modul//platform key> <----- imput the password
Enter password for vendor/Modul/security/product_modul//releasekey key> <----- imput the password
Enter password for vendor/Modul/security/product_modul//shared key> <----- imput the password
rewriting RECOVERY/RAMDISK/default.prop:
replace: ro.build.tags=test-keys
with: ro.build.tags=release-keys
NOT signing: CalendarWidget.apk
NOT signing: Contacts_yellowpage.apk
signing: Mms.apk
signing: SoundRecorder.apk
signing: AccountAndSyncSettings.apk
signing: Camera.apk
.......................................................................
rewriting SYSTEM/build.prop:
replace: ro.build.tags=test-keys
with: ro.build.tags=release-keys
replace: ro.build.description= test-keys
with: ro.build.description= release-keys
replace: ro.build.fingerprint=...........................
with: ro.build.fingerprint=.............................
signing: framework-res.apk
done.
这样就完成了android系统的签名工作.
再生成最终的image文件
~/work/Android.01/out/dist$ ./build/tools/releasetools/img_from_target_files out/dist/signed-target-files.zip out/dist/signed-img.zip
creating boot.img...
creating recovery.img...
creating system.img...
creating userdata.img...
cleaning up...
done.
使用img_from_target_files工具生成signed-img.zip文件.signed-img.zip文件包含了boot.img,userdate.img,system.img文件等.