手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

Android如何用命令行进行打包

时间:2024-11-06 00:07:16

1、把android命令行工具所在的路径添加到path环境变量中,主要包括:D:\adt-bundle-windows-x86_64-20131115\sdk\tools;D:\adt-bundle-windows-x86_64-20131115\sdk\platform-tools;D:\adt-bundle-windows-x86_64-20131115\sdk\build-tools\19.0.1;

Android如何用命令行进行打包

2、我们在eclipse中新建一个android项目,内容非常简单,只有一个MainActivity。

Android如何用命令行进行打包

3、下面我们把这个项目的源码拷贝到其他的路径,然后用命令行进行打包,比如本文是拷贝到D:\work\taobao-wireless\android\安全\命令行打包\hellodemo。

4、(1)生成R文件。在命令行输入:aapt package -f -m -J ./gen -S res -M AndroidManifest.xml -I D:\adt-bundle-windows-x86_64-20131115\sdk\platforms\android-19\android.jar

Android如何用命令行进行打包

5、(2)生成class文件。在命令行输入:javac -bootclasspath D:\adt-bundle-windows-x86_64-20131115\sdk\platforms\android-19\android.jar -d bin src\com\example\hello\*.java gen\com\example\hello\R.java

Android如何用命令行进行打包

6、(3)把class文件打成jar包。在命令行输入:cd binjar cvf hello.jar *

Android如何用命令行进行打包

7、(4)生成dex文件。在命令行输入:cd ..dx --dex --output=bin\classes.dex bin\hello.jar

Android如何用命令行进行打包

8、(5)打包资源。在命令行输入:aapt package -f -M AndroidManifest.xml -S res -I D:\adt-bundle-windows-x86_64-20131115\sdk\platforms\android-19\android.jar -F bin\resources.ap_

Android如何用命令行进行打包

9、(6)生成未签名的apk。在命令行输入:java -cp D:\adt-bundle-windows-x86_64-20131115\sdk\tools\lib\sdklib.jar com.android.sdklib.build.ApkBuilderMain hello.apk -v -u -z bin\resources.ap_ -f bin\classes.dex -rf src

Android如何用命令行进行打包

10、(7)对apk进行签名。在命令行输入:cd ../../Auto-signjava -jar signapk.jar testkey.x509.pem testkey.pk8 ../命令行打包/hellodemo/hello.apk ../命令行打包/hellodemo/hellosign.apk

Android如何用命令行进行打包

11、现在就可以adb installhellosign.apk进行安装了。

Android如何用命令行进行打包
© 手抄报圈