eclipse 使用命令行build apk

首先进入SDK的build-tools\24.0.2下

#build R file

aapt p -f -m -J C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\gen -S C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\res -I C:\Users\lucy.li\Desktop\E\software\android-2.1_r01-windows\platforms\android-24\android.jar -M C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\AndroidManifest.xml

#build .class file(-source 1.6 此参数强制使用1.6版本可以解决版本不匹配问题)

javac -encoding GBK -source 1.6  -target 1.6 -bootclasspath C:\Users\lucy.li\Desktop\E\software\android-2.1_r01-windows\platforms\android-24\android.jar -d C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\bin\classes C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\src\com\example\mg20testapplication\*.java C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\gen\com\example\mg20testapplication\R.java -classpath C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\runtime\mgsdk-20.ja

#build resources.ap_r

aapt package -f -S C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\res -I C:\Users\lucy.li\Desktop\E\software\android-2.1_r01-windows\platforms\android-24\android.jar -A C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\assets -M C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\AndroidManifest.xml -F C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\bin\resources.ap_

#build classes.dex(--no-strict此参数可以解决path err相关问题)

dx --dex --no-strict --output=C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\bin\classes.dex C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\bin\classes\com\example\mg20testapplication

#build apk ( 需要先进入SDK的tools目录下,新版的SDK没有apkbuilder .bat; 可以找一个旧版的)

apkbuilder C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\bin\123.apk -v -u -z C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\bin\resources.ap_ -f C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\bin\classes.dex -rf C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\src -nf C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\libs

#使用默认keystore签名

jarsigner -verbose -keystore C:\Users\lucy.li\.android\debug.keystore -signedjar C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\bin\MG20SelfLoad_sign.apk C:\Users\lucy.li\Desktop\E\eclipse_workspace\MG20SelfLoad\bin\MG20SelfLoad.apk androiddebugkey -storepass android lucy.li


在该路径下找到debug.keystore证书 :C:\Users\\.Android

-keystore 证书文件路径

-verbose  显示所有信息

-signedjar 签名后的APK路径,  签名前的APK路径 

androiddebugkey  为debug.keystore别名

-storepass 证书密码

也可以用自己生成的keystore,注意要记住密码!!!

未签名的apk没有meta-info文件夹。无法install到手机里的。

你可能感兴趣的:(eclipse)