Android 命令行手动编译打包详解
2010-08-11 10:56:00 来源:WEB开发网例:
F:explorerAndroidByread>F:explorerandroid-sdk-windows2.2platformsandroid-3 oolsdx.bat --dex --output=F:explorerAndroidByreadinclasses.dex f:explorerAndroidByreadinclasses
其中classes.dex为生成的目标文件,f:explorerAndroidByreadinclasses为class文件所在目录
5使用Android SDK提供的aapt.exe生成资源包文件(包括res、assets、androidmanifest.xml等):
F:explorerAndroidByread>F:explorerandroid-sdk-windows2.2platformsandroid-3 oolsaapt.exe package -f -M AndroidManifest.xml -S res -A assets -I F:explorerandroid-sdk-windows2.2platformsandroid-3android.jar -F binyreadreader
将AndroidManifest.xml,res和assets文件夹中的资源文件打包生成byreadreader,用法参见1
6第六步 生成未签名的apk安装文件:
apkbuilder ${output.apk.file} -u -z ${packagedresource.file} -f ${dex.file} -rf ${source.dir} -rj ${libraries.dir}
例:
F:explorerAndroidByread>f:explorerandroid-sdk-windows2.2 oolsapkbuilder.bat f:exploreryreadreader.apk ?v -u -z f:explorerAndroidByreadinyreadreader -f f:explorerAndroidByreadinclass.dex -rf F:explorerAndroidByreadsrc
其中f:exploreryreadreader.apk为生成的apk ,-z f:explorerAndroidByreadinyreadreader为资源包,f:explorerAndroidByread inclass.dex为类文件包
7使用jdk的jarsigner对未签名的包进行apk签名:
use jarsigner
jarsigner -keystore ${keystore} -storepass ${keystore.password} -keypass ${keypass} -signedjar ${signed.apkfile} ${unsigned.apkfile} ${keyalias}
例如:
F:explorerandroid-sdk-windows2.2 ools>jarsigner ?keystore f:explorereclipse3.5byread.keystore -storepass byread002 -keypass byread002 -signedjar f:exploreryread.apk f:exploreryreadreader.apk byread
其中?keystore f:explorereclipse3.5byread.keystore 为密钥文件 -storepass byread002为密钥文件密码 byread 为密钥别名 -keypass byread002为密钥别名密码,-signedjar f:exploreryread.apk为签名后生成的apk文件 f:exploreryreadreader.apk为未签名的文件。
参考:http://asantoso.wordpress.com/2009/09/15/how-to-build-android- application-package-apk-from-the-command-line-using-the-sdk-tools-continuously-integrated-using-cruisecontrol/
更多精彩
赞助商链接