Android:linux下aapt使用

Android:linux下aapt使用

aapt stands for Android Asset Packaging Tool and is included in the tools/ directory of the SDK. This tool allows you to view, create, and update Zip-compatible archives (zip, jar, apk). It can also compile resources into binary assets.

Though you probably won't often use aapt directly, build scripts and IDE plugins can utilize this tool to package the apk file that constitutes an Android application.

For more usage details, open a terminal, go to the tools/ directory, and run the command:

· Linux or Mac OS X:

./aapt

· Windows:

aapt.exe

eg: 
进入/home/jack/android/cupcake/out/host/linux-x86/bin目录下
(一),生成资源apk包,由以下命令完成:
./aapt package -z -u -x -M /home/jack/android/cupcake/frameworks/base/core/res/AndroidManifest.xml -S /home/jack/android/cupcake/frameworks/base/core/res/res
(二)第二步,为生成的资源包做签名:
java -jar /home/jack/android/cupcake/out/host/linux-x86/framework/signapk.jar /home/jack/android/cupcake/build/target/product/security/platform.x509.pem /home/jack/android/cupcake/build/target/product/security/platform.pk8 /home/jack/android/cupcake/out/target/product/generic/obj/APPS/framework-res_intermediates/package.apk.unsigned /home/jack/android/cupcake/out/target/product/generic/obj/APPS/framework-res_intermediates/package.apk.signed
(三)第三步,为生成的包做对齐处理:
./zipalign -f 4 /home/jack/android/cupcake/out/target/product/generic/obj/APPS/framework-res_intermediates/package.apk.unaligned /home/jack/android/cupcake/out/target/product/generic/obj/APPS/framework-res_intermediates/package.apk.aligned
命令解释如下
aapt p[ackage] [-d][-f][-m][-u][-v][-x][-z][-M AndroidManifest.xml] /
        [-0 extension [-0 extension ...]] /
        [-g tolerance] /
        [-j jarfile] /
        [-I base-package [-I base-package ...]] /
        [-A asset-source-dir] [-P public-definitions-file] /
        [-S resource-sources [-S resource-sources ...]]         [-F apk-file] [-J R-file-dir] /
        [raw-files-dir [raw-files-dir] ...]

   Package the android resources. It will read assets and resources that are
   supplied with the -M -A -S or raw-files-dir arguments. The -J -P -F and -R
   options control which files are output.

cd /home/jack/eclipse_rcp_wk/HELLLO/bin
jar -cvf XX.jar *.*   (java jar 打包   xx.jar)


zipalign 这个命令?

如此生成的framework-res.apk包可以被用来替换system.img中的资源包。

具体步骤:

1. 首先用生成的framework-res.apk替换在~/android/src/out/target/product/generic/system/framework中的同名文件。 

2. 用make snod生成新的system.img, 

3. 用-wipe-date参数启动emulator 

4. Error bootstrapping switch '/sys/classs/witch/test'”    错误 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值