User Tools

Site Tools


android:build-with-ant

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
android:build-with-ant [2010/07/02 21:22] – created percyandroid:build-with-ant [2016/05/05 13:07] (current) – external edit 127.0.0.1
Line 5: Line 5:
  
 今天在Gentoo下试了下,没有做任何设置ant就可以用了,应该是以前我不知不觉就安装好了。 今天在Gentoo下试了下,没有做任何设置ant就可以用了,应该是以前我不知不觉就安装好了。
 +
 +===== 安装ant =====
  
 如果是在Windows下,需要到网站上去下载:http://ant.apache.org/bindownload.cgi 如果是在Windows下,需要到网站上去下载:http://ant.apache.org/bindownload.cgi
  
 再设置好环境变量,这个就不说了。 再设置好环境变量,这个就不说了。
 +
 +
 +===== 使用android命令创建工程 =====
  
 ant编译需要依赖于build.xml文件,如果是用Eclipse生成的工程,是没有这个文件的。显然Google支持ant编译自然不会让我们去手动生成的文件了,她为我们准备了android命令: ant编译需要依赖于build.xml文件,如果是用Eclipse生成的工程,是没有这个文件的。显然Google支持ant编译自然不会让我们去手动生成的文件了,她为我们准备了android命令:
Line 54: Line 59:
 Added file ./AndroidAnt/build.xml Added file ./AndroidAnt/build.xml
 </code> </code>
-很明显目录结构和用Eclipse生成的一样,多了build.xml,这个就是为了在命令行用ant编译而准备的。+很明显目录结构和用Eclipse生成的一样,只是多了build.xml,这个就是为了在命令行用ant编译而准备的。 
 +===== 使用ant编译Android工程 =====
  
 编译这个新生成的工程 编译这个新生成的工程
Line 89: Line 95:
 </code> </code>
 使用ant debug来生成用debug key签名的APK。 使用ant debug来生成用debug key签名的APK。
 +  ant debug
 +<code>
 +pjq@gentoo-pjq ~/android/workspace/AndroidAnt $ ant debug
 +Buildfile: /home/pjq/android/workspace/AndroidAnt/build.xml
 +    [setup] Android SDK Tools Revision 6
 +    [setup] Project Target: Android 2.2
 +    [setup] API level: 8
 +    [setup] WARNING: No minSdkVersion value set. Application will install on all Android versions.
 +    [setup] Importing rules file: platforms/android-8/ant/ant_rules_r2.xml
 +
 +-compile-tested-if-test:
 +
 +-dirs:
 +     [echo] Creating output directories if needed...
 +    [mkdir] Created dir: /home/pjq/android/workspace/AndroidAnt/gen
 +    [mkdir] Created dir: /home/pjq/android/workspace/AndroidAnt/bin/classes
 +
 +-resource-src:
 +     [echo] Generating R.java / Manifest.java from the resources...
 +
 +-aidl:
 +     [echo] Compiling aidl files into Java classes...
 +
 +compile:
 +    [javac] /home/pjq/android/android-sdk-linux_86/platforms/android-8/ant/ant_rules_r2.xml:255: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
 +    [javac] Compiling 2 source files to /home/pjq/android/workspace/AndroidAnt/bin/classes
 +
 +-dex:
 +     [echo] Converting compiled files and external libraries into /home/pjq/android/workspace/AndroidAnt/bin/classes.dex...
 +
 +-package-resources:
 +     [echo] Packaging resources
 + [aaptexec] Creating full resource package...
 +
 +-package-debug-sign:
 +[apkbuilder] Creating AndroidAnt-debug-unaligned.apk and signing it with a debug key...
 +[apkbuilder] Using keystore: /home/pjq/.android/debug.keystore
 +
 +debug:
 +     [echo] Running zip align on final apk...
 +     [echo] Debug Package: /home/pjq/android/workspace/AndroidAnt/bin/AndroidAnt-debug.apk
 +
 +BUILD SUCCESSFUL
 +Total time: 8 seconds
 +</code>
 +呃,这个过程好熟悉,想起来了,之前TweeQ就是这样编译的。
 +
 +===== 安装APK =====
 +再使用adb install 安装APK
 +  adb install bin/AndroidAnt-debug.apk
  
  
/var/www/dokuwiki/wiki/data/attic/android/build-with-ant.1278076952.txt.gz · Last modified: 2016/05/05 13:06 (external edit)