[android]android自动化测试六之命令行编译APK
程序员文章站
2022-05-10 23:33:51
...
手动编译你的apk,可以让资源目录不命名为res, 你能够命名任何你想要的名字。
你可以在以下目录发现ant脚本: <SDK_HOME>/platforms/android-1.5/templates/android-rules.xml
第一步: 产生R文件以及包资源
aapt package -f -M ${manifest.file} -F ${packaged.resource.file} -I ${path.to.android-jar.library} -S ${android-resource-directory} [-m -J ${folder.to.output.the.R.java}]
第二步:编译java源文件以及R.java文件
use javac
第三步:将classes文件转化成Dalvik自节码
use dx.bat
dx.bat –dex –output=${output.dex.file} ${compiled.classes.directory} ${jar files..}
第四步:创建未签名的apk
use apkbuilder
apkbuilder ${output.apk.file} -u -z ${packagedresource.file} -f ${dex.file}
or
apkbuilder ${output.apk.file} -u -z ${packagedresource.file} -f ${dex.file} -rf ${source.dir} -rj ${libraries.dir}
-rf = resources required for compiled source files?
-rj = resources required for jar files
第六步: 产生一个key
use keytool
第七步骤: 对APK进行签名
use jarsigner
jarsigner -keystore ${keystore} -storepass ${keystore.password} -keypass ${keypass} -signedjar ${signed.apkfile} ${unsigned.apkfile} ${keyalias}
第八步: 发布
use adb
adb -d install -r ${signed.apk}
Inspecting your APK file:
aapt list -v latest.apk
Open questions:
1. Can you include more than one dex file in the apk?
2. Can you have dex file named other than classes.dex in the apk?
3. Does an apk have to have a packaged resource?
你可以在以下目录发现ant脚本: <SDK_HOME>/platforms/android-1.5/templates/android-rules.xml
第一步: 产生R文件以及包资源
aapt package -f -M ${manifest.file} -F ${packaged.resource.file} -I ${path.to.android-jar.library} -S ${android-resource-directory} [-m -J ${folder.to.output.the.R.java}]
第二步:编译java源文件以及R.java文件
use javac
第三步:将classes文件转化成Dalvik自节码
use dx.bat
dx.bat –dex –output=${output.dex.file} ${compiled.classes.directory} ${jar files..}
第四步:创建未签名的apk
use apkbuilder
apkbuilder ${output.apk.file} -u -z ${packagedresource.file} -f ${dex.file}
or
apkbuilder ${output.apk.file} -u -z ${packagedresource.file} -f ${dex.file} -rf ${source.dir} -rj ${libraries.dir}
-rf = resources required for compiled source files?
-rj = resources required for jar files
第六步: 产生一个key
use keytool
第七步骤: 对APK进行签名
use jarsigner
jarsigner -keystore ${keystore} -storepass ${keystore.password} -keypass ${keypass} -signedjar ${signed.apkfile} ${unsigned.apkfile} ${keyalias}
第八步: 发布
use adb
adb -d install -r ${signed.apk}
Inspecting your APK file:
aapt list -v latest.apk
Open questions:
1. Can you include more than one dex file in the apk?
2. Can you have dex file named other than classes.dex in the apk?
3. Does an apk have to have a packaged resource?
推荐阅读
-
Android笔记之:App自动化之使用Ant编译项目多渠道打包的使用详解
-
AS+Appium+Java+Win自动化测试之Appium的Java测试脚本封装(Android测试)
-
工欲善其事,必先利其器之—搭建Android(apk)的反编译环境
-
android自动化测试之元素抓取
-
[android]android自动化测试十三之JavaMonkey跨APP操作 chimpchatandroidmonkey
-
[android]android自动化测试九之monkeyRecord
-
[android]android自动化测试四之Monkey与MonkeyRunner
-
[android]android自动化测试二之命令行创建AVD
-
[android]android自动化测试三之设定AVD各项参数
-
[android]android自动化测试六之命令行编译APK