Android_Ant_多渠道打包/一键自动编译 ——Mac lion 10.8.2下

29 篇文章 0 订阅

http://developer.android.com/tools/projects/projects-cmdline.html



1.首先是为项目生成build.xml文件

     执行命令 android update project --name projectName -t 3 -pprojectPath

     效果如下图

http://developer.android.com/tools/projects/projects-cmdline.html


[html]  view plain copy
  1. localhost:android_wardrobe wuyexiong$ android update project --name wardrobe --target 23 --path /Users/wuyexiong/company/android_wardrobe/wardrobe  
  2. Updated project.properties  
  3. Updated local.properties  
  4. Updated file /Users/wuyexiong/company/android_wardrobe/wardrobe/build.xml  
  5. It seems that there are sub-projects. If you want to update them  
  6. please use the --subprojects parameter.  



[html]  view plain copy
  1. localhost:android_wardrobe wuyexiong$ android update project --target 23 --path /Users/wuyexiong/company/android_wardrobe/wardrobe/ --library  /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh/  
  2. Resolved location of library project to: /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh  
  3. Updated project.properties  
  4. Updated local.properties  
  5. It seems that there are sub-projects. If you want to update them  
  6. please use the --subprojects parameter.  


   在项目目录下运行ant,得出如下提示

[html]  view plain copy
  1. help:  
  2.      [echo] Android Ant Build. Available targets:  
  3.      [echo]    help:      Displays this help.  
  4.      [echo]    clean:     Removes output files created by other targets.  
  5.      [echo]               The 'all' target can be used to clean dependencies  
  6.      [echo]               (tested projects and libraries)at the same time  
  7.      [echo]               using: 'ant all clean'  
  8.      [echo]    debug:     Builds the application and signs it with a debug key.  
  9.      [echo]               The 'nodeps' target can be used to only build the  
  10.      [echo]               current project and ignore the libraries using:  
  11.      [echo]               'ant nodeps debug'  
  12.      [echo]    release:   Builds the application. The generated apk file must be  
  13.      [echo]               signed before it is published.  
  14.      [echo]               The 'nodeps' target can be used to only build the  
  15.      [echo]               current project and ignore the libraries using:  
  16.      [echo]               'ant nodeps release'  
  17.      [echo]    instrument:Builds an instrumented package and signs it with a  
  18.      [echo]               debug key.  
  19.      [echo]    test:      Runs the tests. Project must be a test project and  
  20.      [echo]               must have been built. Typical usage would be:  
  21.      [echo]                   ant [emma] debug install test  
  22.      [echo]    emma:      Transiently enables code coverage for subsequent  
  23.      [echo]               targets.  
  24.      [echo]    install:   Installs the newly build package. Must either be used  
  25.      [echo]               in conjunction with a build target (debug/release/  
  26.      [echo]               instrument) or with the proper suffix indicating  
  27.      [echo]               which package to install (see below).  
  28.      [echo]               If the application was previously installed, the  
  29.      [echo]               application is reinstalled if the signature matches.  
  30.      [echo]    installd:  Installs (only) the debug package.  
  31.      [echo]    installr:  Installs (only) the release package.  
  32.      [echo]    installi:  Installs (only) the instrumented package.  
  33.      [echo]    installt:  Installs (only) the test and tested packages (unless  
  34.      [echo]               nodeps is used as well.  
  35.      [echo]    uninstall: Uninstalls the application from a running emulator or  
  36.      [echo]               device. Also uninstall tested package if applicable  
  37.      [echo]               unless 'nodeps' is used as well.  

[html]  view plain copy
  1. localhost:wardrobe wuyexiong$ ant uninstall  
  2. Buildfile: /Users/wuyexiong/company/android_wardrobe/wardrobe/build.xml  
  3.   
  4. -check-env:  
  5.  [checkenv] Android SDK Tools Revision 21  
  6.  [checkenv] Installed at /Users/wuyexiong/Documents/Dev/Android/android-sdk-macosx  
  7.   
  8. -setup:  
  9.      [echo] Project Name: wardrobe  
  10.   [gettype] Project Type: Application  
  11.   
  12. uninstall:  
  13.      [echo] Uninstalling com.haobao.wardrobe from the default emulator or device...  
  14.      [exec] Success  
  15.   
  16. BUILD SUCCESSFUL  
  17. Total time: 2 seconds  
  18. localhost:wardrobe wuyexiong$ ant debug install  
  19. Buildfile: /Users/wuyexiong/company/android_wardrobe/wardrobe/build.xml  
  20.   
  21. -set-mode-check:  
  22.   
  23. -set-debug-files:  
  24.   
  25. -check-env:  
  26.  [checkenv] Android SDK Tools Revision 21  
  27.  [checkenv] Installed at /Users/wuyexiong/Documents/Dev/Android/android-sdk-macosx  
  28.   
  29. -setup:  
  30.      [echo] Project Name: wardrobe  
  31.   [gettype] Project Type: Application  
  32.   
  33. -set-debug-mode:  
  34.   
  35. -debug-obfuscation-check:  
  36.   
  37. -build-setup:  
  38.      [echo] Resolving Build Target for wardrobe...  
  39. [gettarget] Project Target:   Android 4.1.2  
  40. [gettarget] API level:        16  
  41.      [echo] ----------  
  42.      [echo] Creating output directories if needed...  
  43.      [echo] ----------  
  44.      [echo] Resolving Dependencies for wardrobe...  
  45. [dependency] Library dependencies:  
  46. [dependency]   
  47. [dependency] ------------------  
  48. [dependency] Ordered libraries:  
  49.      [echo] ----------  
  50.      [echo] Building Libraries with 'debug'...  
  51.   
  52. nodeps:  
  53.   
  54. -set-mode-check:  
  55.   
  56. -set-debug-files:  
  57.   
  58. -check-env:  
  59.  [checkenv] Android SDK Tools Revision 21  
  60.  [checkenv] Installed at /Users/wuyexiong/Documents/Dev/Android/android-sdk-macosx  
  61.   
  62. -setup:  
  63.      [echo] Project Name: wardrobe_pulltorefresh  
  64.   [gettype] Project Type: Android Library  
  65.   
  66. -set-debug-mode:  
  67.   
  68. -debug-obfuscation-check:  
  69.   
  70. -build-setup:  
  71.      [echo] Resolving Build Target for wardrobe_pulltorefresh...  
  72. [gettarget] Project Target:   Android 4.1.2  
  73. [gettarget] API level:        16  
  74.      [echo] ----------  
  75.      [echo] Creating output directories if needed...  
  76.      [echo] ----------  
  77.      [echo] Resolving Dependencies for wardrobe_pulltorefresh...  
  78. [dependency] Library dependencies:  
  79. [dependency] No Libraries  
  80.   
  81. -pre-build:  
  82.   
  83. -code-gen:  
  84. [mergemanifest] No changes in the AndroidManifest files.  
  85.      [echo] Handling aidl files...  
  86.      [aidl] No AIDL files to compile.  
  87.      [echo] ----------  
  88.      [echo] Handling RenderScript files...  
  89. [renderscript] No RenderScript files to compile.  
  90.      [echo] ----------  
  91.      [echo] Handling Resources...  
  92.      [aapt] No changed resources. R.java and Manifest.java untouched.  
  93.      [echo] ----------  
  94.      [echo] Handling BuildConfig class...  
  95. [buildconfig] No need to generate new BuildConfig.  
  96.   
  97. -pre-compile:  
  98.   
  99. -compile:  
  100.      [echo] Creating library output jar file...  
  101.   
  102. -post-compile:  
  103.   
  104. -obfuscate:  
  105.   
  106. -dex:  
  107.      [echo] Library project: do not convert bytecode...  
  108.   
  109. -crunch:  
  110.    [crunch] Crunching PNG Files in source dir: /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh/res  
  111.    [crunch] To destination dir: /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh/bin/res  
  112.    [crunch] Crunched 0 PNG files to update cache  
  113.   
  114. -package-resources:  
  115.      [echo] Library project: do not package resources...  
  116.   
  117. -package:  
  118.      [echo] Library project: do not package apk...  
  119.   
  120. -post-package:  
  121.   
  122. -do-debug:  
  123.      [echo] Library project: do not create apk...  
  124. [propertyfile] Updating property file: /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh/bin/build.prop  
  125. [propertyfile] Updating property file: /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh/bin/build.prop  
  126. [propertyfile] Updating property file: /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh/bin/build.prop  
  127. [propertyfile] Updating property file: /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh/bin/build.prop  
  128.   
  129. -post-build:  
  130.   
  131. debug:  
  132.   
  133. -pre-build:  
  134.   
  135. -code-gen:  
  136. [mergemanifest] No changes in the AndroidManifest files.  
  137.      [echo] Handling aidl files...  
  138.      [aidl] No AIDL files to compile.  
  139.      [echo] ----------  
  140.      [echo] Handling RenderScript files...  
  141. [renderscript] No RenderScript files to compile.  
  142.      [echo] ----------  
  143.      [echo] Handling Resources...  
  144.      [aapt] No changed resources. R.java and Manifest.java untouched.  
  145.      [echo] ----------  
  146.      [echo] Handling BuildConfig class...  
  147. [buildconfig] No need to generate new BuildConfig.  
  148.   
  149. -pre-compile:  
  150.   
  151. -compile:  
  152.   
  153. -post-compile:  
  154.   
  155. -obfuscate:  
  156.   
  157. -dex:  
  158.       [dex] input: /Users/wuyexiong/company/android_wardrobe/wardrobe/bin/classes  
  159.       [dex] input: /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh/bin/classes.jar  
  160.       [dex] input: /Users/wuyexiong/company/android_wardrobe/wardrobe/libs/gson-2.2.2.jar  
  161.       [dex] input: /Users/wuyexiong/company/android_wardrobe/wardrobe/libs/umeng_sdk.jar  
  162.       [dex] input: /Users/wuyexiong/company/android_wardrobe/wardrobe/libs/android-support-v4.jar  
  163.       [dex] Using Pre-Dexed classes-a1f893dd4075b58ecd2f0da685f2ab7a.jar <- /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh/bin/classes.jar  
  164.       [dex] Using Pre-Dexed gson-2.2.2-de6fbe71bf7663e94351648f04d14d3e.jar <- /Users/wuyexiong/company/android_wardrobe/wardrobe/libs/gson-2.2.2.jar  
  165.       [dex] Using Pre-Dexed umeng_sdk-bfaefaa81d40319afd9177a431101238.jar <- /Users/wuyexiong/company/android_wardrobe/wardrobe/libs/umeng_sdk.jar  
  166.       [dex] Using Pre-Dexed android-support-v4-48870b25fa653c73e5a248db2a3e5e6f.jar <- /Users/wuyexiong/company/android_wardrobe/wardrobe/libs/android-support-v4.jar  
  167.       [dex] No new compiled code. No need to convert bytecode to dalvik format.  
  168.   
  169. -crunch:  
  170.    [crunch] Crunching PNG Files in source dir: /Users/wuyexiong/company/android_wardrobe/wardrobe/res  
  171.    [crunch] To destination dir: /Users/wuyexiong/company/android_wardrobe/wardrobe/bin/res  
  172.    [crunch] Crunched 0 PNG files to update cache  
  173.   
  174. -package-resources:  
  175.      [aapt] No changed resources or assets. wardrobe.ap_ remains untouched  
  176.   
  177. -package:  
  178. [apkbuilder] No changes. No need to create apk.  
  179.   
  180. -post-package:  
  181.   
  182. -do-debug:  
  183.  [zipalign] Run cancelled: no changes to input file /Users/wuyexiong/company/android_wardrobe/wardrobe/bin/wardrobe-debug-unaligned.apk  
  184.      [echo] Debug Package: /Users/wuyexiong/company/android_wardrobe/wardrobe/bin/wardrobe-debug.apk  
  185. [propertyfile] Updating property file: /Users/wuyexiong/company/android_wardrobe/wardrobe/bin/build.prop  
  186. [propertyfile] Updating property file: /Users/wuyexiong/company/android_wardrobe/wardrobe/bin/build.prop  
  187. [propertyfile] Updating property file: /Users/wuyexiong/company/android_wardrobe/wardrobe/bin/build.prop  
  188. [propertyfile] Updating property file: /Users/wuyexiong/company/android_wardrobe/wardrobe/bin/build.prop  
  189.   
  190. -post-build:  
  191.   
  192. debug:  
  193.   
  194. install:  
  195.      [echo] Installing /Users/wuyexiong/company/android_wardrobe/wardrobe/bin/wardrobe-debug.apk onto default emulator or device...  
  196.      [exec] 4441 KB/s (869375 bytes in 0.191s)  
  197.      [exec]     pkg: /data/local/tmp/wardrobe-debug.apk  
  198.      [exec] Success  
  199.   
  200. BUILD SUCCESSFUL  





ubuntu12.10下编译会出错。

BUILD FAILED
/home/wuyexiong/company/android_wardrobe/wardrobe/build.xml:90: The following error occurred while executing this line:
/home/wuyexiong/Android/android-linux/adt-bundle-linux-x86_64/sdk/tools/ant/build.xml:206: No supported regular expression matcher found: java.lang.ClassNotFoundException: org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp

Total time: 0 seconds
wuyexiong@wuyexiong-System-Product-Name:~/company/android_wardrobe/wardrobe$ sudo apt-get install ant-optional

安装一个最新的ant 搞定

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值