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

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


localhost:android_wardrobe wuyexiong$ android update project --name wardrobe --target 23 --path /Users/wuyexiong/company/android_wardrobe/wardrobe
Updated project.properties
Updated local.properties
Updated file /Users/wuyexiong/company/android_wardrobe/wardrobe/build.xml
It seems that there are sub-projects. If you want to update them
please use the --subprojects parameter.



localhost:android_wardrobe wuyexiong$ android update project --target 23 --path /Users/wuyexiong/company/android_wardrobe/wardrobe/ --library  /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh/
Resolved location of library project to: /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh
Updated project.properties
Updated local.properties
It seems that there are sub-projects. If you want to update them
please use the --subprojects parameter.


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

help:
     [echo] Android Ant Build. Available targets:
     [echo]    help:      Displays this help.
     [echo]    clean:     Removes output files created by other targets.
     [echo]               The 'all' target can be used to clean dependencies
     [echo]               (tested projects and libraries)at the same time
     [echo]               using: 'ant all clean'
     [echo]    debug:     Builds the application and signs it with a debug key.
     [echo]               The 'nodeps' target can be used to only build the
     [echo]               current project and ignore the libraries using:
     [echo]               'ant nodeps debug'
     [echo]    release:   Builds the application. The generated apk file must be
     [echo]               signed before it is published.
     [echo]               The 'nodeps' target can be used to only build the
     [echo]               current project and ignore the libraries using:
     [echo]               'ant nodeps release'
     [echo]    instrument:Builds an instrumented package and signs it with a
     [echo]               debug key.
     [echo]    test:      Runs the tests. Project must be a test project and
     [echo]               must have been built. Typical usage would be:
     [echo]                   ant [emma] debug install test
     [echo]    emma:      Transiently enables code coverage for subsequent
     [echo]               targets.
     [echo]    install:   Installs the newly build package. Must either be used
     [echo]               in conjunction with a build target (debug/release/
     [echo]               instrument) or with the proper suffix indicating
     [echo]               which package to install (see below).
     [echo]               If the application was previously installed, the
     [echo]               application is reinstalled if the signature matches.
     [echo]    installd:  Installs (only) the debug package.
     [echo]    installr:  Installs (only) the release package.
     [echo]    installi:  Installs (only) the instrumented package.
     [echo]    installt:  Installs (only) the test and tested packages (unless
     [echo]               nodeps is used as well.
     [echo]    uninstall: Uninstalls the application from a running emulator or
     [echo]               device. Also uninstall tested package if applicable
     [echo]               unless 'nodeps' is used as well.

localhost:wardrobe wuyexiong$ ant uninstall
Buildfile: /Users/wuyexiong/company/android_wardrobe/wardrobe/build.xml

-check-env:
 [checkenv] Android SDK Tools Revision 21
 [checkenv] Installed at /Users/wuyexiong/Documents/Dev/Android/android-sdk-macosx

-setup:
     [echo] Project Name: wardrobe
  [gettype] Project Type: Application

uninstall:
     [echo] Uninstalling com.haobao.wardrobe from the default emulator or device...
     [exec] Success

BUILD SUCCESSFUL
Total time: 2 seconds
localhost:wardrobe wuyexiong$ ant debug install
Buildfile: /Users/wuyexiong/company/android_wardrobe/wardrobe/build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 21
 [checkenv] Installed at /Users/wuyexiong/Documents/Dev/Android/android-sdk-macosx

-setup:
     [echo] Project Name: wardrobe
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-build-setup:
     [echo] Resolving Build Target for wardrobe...
[gettarget] Project Target:   Android 4.1.2
[gettarget] API level:        16
     [echo] ----------
     [echo] Creating output directories if needed...
     [echo] ----------
     [echo] Resolving Dependencies for wardrobe...
[dependency] Library dependencies:
[dependency] 
[dependency] ------------------
[dependency] Ordered libraries:
     [echo] ----------
     [echo] Building Libraries with 'debug'...

nodeps:

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 21
 [checkenv] Installed at /Users/wuyexiong/Documents/Dev/Android/android-sdk-macosx

-setup:
     [echo] Project Name: wardrobe_pulltorefresh
  [gettype] Project Type: Android Library

-set-debug-mode:

-debug-obfuscation-check:

-build-setup:
     [echo] Resolving Build Target for wardrobe_pulltorefresh...
[gettarget] Project Target:   Android 4.1.2
[gettarget] API level:        16
     [echo] ----------
     [echo] Creating output directories if needed...
     [echo] ----------
     [echo] Resolving Dependencies for wardrobe_pulltorefresh...
[dependency] Library dependencies:
[dependency] No Libraries

-pre-build:

-code-gen:
[mergemanifest] No changes in the AndroidManifest files.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
[renderscript] No RenderScript files to compile.
     [echo] ----------
     [echo] Handling Resources...
     [aapt] No changed resources. R.java and Manifest.java untouched.
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] No need to generate new BuildConfig.

-pre-compile:

-compile:
     [echo] Creating library output jar file...

-post-compile:

-obfuscate:

-dex:
     [echo] Library project: do not convert bytecode...

-crunch:
   [crunch] Crunching PNG Files in source dir: /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh/res
   [crunch] To destination dir: /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh/bin/res
   [crunch] Crunched 0 PNG files to update cache

-package-resources:
     [echo] Library project: do not package resources...

-package:
     [echo] Library project: do not package apk...

-post-package:

-do-debug:
     [echo] Library project: do not create apk...
[propertyfile] Updating property file: /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh/bin/build.prop
[propertyfile] Updating property file: /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh/bin/build.prop
[propertyfile] Updating property file: /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh/bin/build.prop
[propertyfile] Updating property file: /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh/bin/build.prop

-post-build:

debug:

-pre-build:

-code-gen:
[mergemanifest] No changes in the AndroidManifest files.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
[renderscript] No RenderScript files to compile.
     [echo] ----------
     [echo] Handling Resources...
     [aapt] No changed resources. R.java and Manifest.java untouched.
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] No need to generate new BuildConfig.

-pre-compile:

-compile:

-post-compile:

-obfuscate:

-dex:
      [dex] input: /Users/wuyexiong/company/android_wardrobe/wardrobe/bin/classes
      [dex] input: /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh/bin/classes.jar
      [dex] input: /Users/wuyexiong/company/android_wardrobe/wardrobe/libs/gson-2.2.2.jar
      [dex] input: /Users/wuyexiong/company/android_wardrobe/wardrobe/libs/umeng_sdk.jar
      [dex] input: /Users/wuyexiong/company/android_wardrobe/wardrobe/libs/android-support-v4.jar
      [dex] Using Pre-Dexed classes-a1f893dd4075b58ecd2f0da685f2ab7a.jar <- /Users/wuyexiong/company/android_wardrobe/wardrobe_pulltorefresh/bin/classes.jar
      [dex] Using Pre-Dexed gson-2.2.2-de6fbe71bf7663e94351648f04d14d3e.jar <- /Users/wuyexiong/company/android_wardrobe/wardrobe/libs/gson-2.2.2.jar
      [dex] Using Pre-Dexed umeng_sdk-bfaefaa81d40319afd9177a431101238.jar <- /Users/wuyexiong/company/android_wardrobe/wardrobe/libs/umeng_sdk.jar
      [dex] Using Pre-Dexed android-support-v4-48870b25fa653c73e5a248db2a3e5e6f.jar <- /Users/wuyexiong/company/android_wardrobe/wardrobe/libs/android-support-v4.jar
      [dex] No new compiled code. No need to convert bytecode to dalvik format.

-crunch:
   [crunch] Crunching PNG Files in source dir: /Users/wuyexiong/company/android_wardrobe/wardrobe/res
   [crunch] To destination dir: /Users/wuyexiong/company/android_wardrobe/wardrobe/bin/res
   [crunch] Crunched 0 PNG files to update cache

-package-resources:
     [aapt] No changed resources or assets. wardrobe.ap_ remains untouched

-package:
[apkbuilder] No changes. No need to create apk.

-post-package:

-do-debug:
 [zipalign] Run cancelled: no changes to input file /Users/wuyexiong/company/android_wardrobe/wardrobe/bin/wardrobe-debug-unaligned.apk
     [echo] Debug Package: /Users/wuyexiong/company/android_wardrobe/wardrobe/bin/wardrobe-debug.apk
[propertyfile] Updating property file: /Users/wuyexiong/company/android_wardrobe/wardrobe/bin/build.prop
[propertyfile] Updating property file: /Users/wuyexiong/company/android_wardrobe/wardrobe/bin/build.prop
[propertyfile] Updating property file: /Users/wuyexiong/company/android_wardrobe/wardrobe/bin/build.prop
[propertyfile] Updating property file: /Users/wuyexiong/company/android_wardrobe/wardrobe/bin/build.prop

-post-build:

debug:

install:
     [echo] Installing /Users/wuyexiong/company/android_wardrobe/wardrobe/bin/wardrobe-debug.apk onto default emulator or device...
     [exec] 4441 KB/s (869375 bytes in 0.191s)
     [exec] 	pkg: /data/local/tmp/wardrobe-debug.apk
     [exec] Success

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 搞定

你可能感兴趣的:(Android_Ant_多渠道打包/一键自动编译 ——Mac lion 10.8.2下)