使用ant编译android工程
16lz
2021-01-23
使用ant编译android工程 The good thing about building manually your apk is that you don’t have to name your resources directory to res, you can name it anything you want.
You can find ant scripts in: \platforms\android-1.5\templates\android-rules.xml
Step 1: Generate Resource java code and packaged Resources
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}]
Step 2: Compile java source codes + R.java
use javac
Step 3: Convert classes to Dalvik bytecodes
use dx.bat
dx.bat –dex –output=${output.dex.file} ${compiled.classes.directory} ${jar files..}
Step 4: Create unsigned 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
Step 6: Generate a key
use keytool
Step 7: Sign APK
use jarsigner
jarsigner -keystore ${keystore} -storepass ${keystore.password} -keypass ${keypass} -signedjar ${signed.apkfile} ${unsigned.apkfile} ${keyalias}
Step 8: Publish
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?
Note: If upon installing your app using adb you see this error code FAILED_INSTALL_DEXOPT then most likely that either you don’t have classes.dex or you don’t have a packaged resource in the 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/
You can find ant scripts in: \platforms\android-1.5\templates\android-rules.xml
Step 1: Generate Resource java code and packaged Resources
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}]
Step 2: Compile java source codes + R.java
use javac
Step 3: Convert classes to Dalvik bytecodes
use dx.bat
dx.bat –dex –output=${output.dex.file} ${compiled.classes.directory} ${jar files..}
Step 4: Create unsigned 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
Step 6: Generate a key
use keytool
Step 7: Sign APK
use jarsigner
jarsigner -keystore ${keystore} -storepass ${keystore.password} -keypass ${keypass} -signedjar ${signed.apkfile} ${unsigned.apkfile} ${keyalias}
Step 8: Publish
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?
Note: If upon installing your app using adb you see this error code FAILED_INSTALL_DEXOPT then most likely that either you don’t have classes.dex or you don’t have a packaged resource in the 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/
更多相关文章
- Android全工程编译不过问题汇总
- 新sdk(5.0+)eclipse建android工程报错
- 【Gradle】自定义Android Gradle工程
- android 开发 新建工程
- Android Studio 首次创建工程下载Gradle失败
- cocos2d-2.1rc0-x-2.1.3建android工程Hello World例子
- Android初级工程师面试题答案——Android题型