dev android project from cmd
前置条件:(1)ubuntuシステム、(2)PATHを構成し、
具体的には以下の通りです.
ホームディレクトリのbashrcファイルのexport PATHの前に、次の行を追加します.
1.使用可能なsdkをリストする(出力は付録1参照)
2.プロジェクトの作成
既存のeclipseプロジェクトではandroid update projectコマンド(詳細は後述の参照リンクを参照)を使用して更新でき、端末でコンパイルできます.3.シミュレータを起動する(本体がスキップ可能)
4.プロジェクトルートディレクトリの下:(実行出力は本付録2を参照)
5.シミュレータに適用するインストール
付録(1)android list targetの出力:
付録(2)ant debugの出力:
上から参照:
http://developer.android.com/intl/zh-CN/training/basics/firstapp/index.html
具体的には以下の通りです.
ホームディレクトリのbashrcファイルのexport PATHの前に、次の行を追加します.
# add by banxi for android development
PATH="$PATH:~/android/android-sdk-linux_x86/platform-tools:~/android/android-sdk-linux_x86/tools"
1.使用可能なsdkをリストする(出力は付録1参照)
android list target
2.プロジェクトの作成
~/work/cmd_dev_android$ android create project --target 6 --name MyFirstApp --path MyFirstApp --activity MainActivity --package com.banxi.appone
既存のeclipseプロジェクトではandroid update projectコマンド(詳細は後述の参照リンクを参照)を使用して更新でき、端末でコンパイルできます.3.シミュレータを起動する(本体がスキップ可能)
android avd
4.プロジェクトルートディレクトリの下:(実行出力は本付録2を参照)
ant debug
5.シミュレータに適用するインストール
adb install bin/MyFirstApp-debug.apk
付録(1)android list targetの出力:
banxi1988@banxi :~$ android list target
Available Android targets:
----------
id: 1 or "android-7"
Name: Android 2.1
Type: Platform
API level: 7
Revision: 3
Skins: WVGA854, WVGA800 (default), WQVGA400, WQVGA432, QVGA, HVGA
ABIs : armeabi
----------
id: 2 or "android-8"
Name: Android 2.2
Type: Platform
API level: 8
Revision: 3
Skins: WVGA854, WVGA800 (default), WQVGA400, WQVGA432, QVGA, HVGA
ABIs : armeabi
----------
id: 3 or "android-10"
Name: Android 2.3.3
Type: Platform
API level: 10
Revision: 2
Skins: WVGA854, WVGA800 (default), WQVGA400, WQVGA432, QVGA, HVGA
ABIs : armeabi
----------
id: 4 or "android-14"
Name: Android 4.0
Type: Platform
API level: 14
Revision: 3
Skins: WXGA720, WSVGA, WVGA854, WVGA800 (default), WQVGA400, WQVGA432, WXGA800, QVGA, HVGA
ABIs : no ABIs.
----------
id: 5 or "android-15"
Name: Android 4.0.3
Type: Platform
API level: 15
Revision: 3
Skins: WXGA720, WSVGA, WVGA854, WVGA800 (default), WQVGA400, WQVGA432, WXGA800, QVGA, HVGA
ABIs : armeabi-v7a
----------
id: 6 or "android-16"
Name: Android 4.1
Type: Platform
API level: 16
Revision: 1
Skins: WXGA720, WSVGA, WVGA854, WXGA800-7in, WVGA800 (default), WQVGA400, WQVGA432, WXGA800, QVGA, HVGA
ABIs : armeabi-v7a
----------
id: 7 or "Google Inc.:Google APIs:16"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 2
Description: Android + Google APIs
Based on Android 4.1 (API level 16)
Libraries:
* com.google.android.media.effects (effects.jar)
Collection of video effects
* com.android.future.usb.accessory (usb.jar)
API for USB Accessories
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: WQVGA400, WVGA854, WSVGA, WXGA800-7in, WXGA720, HVGA, WQVGA432, QVGA, WVGA800 (default), WXGA800
ABIs : armeabi-v7a
banxi1988@banxi :~$
付録(2)ant debugの出力:
banxi1988@banxi :~/work/cmd_dev_android/MyFirstApp$ ant debug
Buildfile: /home/banxi1988/work/cmd_dev_android/MyFirstApp/build.xml
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 20
[checkenv] Installed at /home/banxi1988/android/android-sdk-linux_x86
-setup:
[echo] Project Name: MyFirstApp
[gettype] Project Type: Application
[echo] Switching between debug and non debug build: Deleting previous compilation output...
-set-debug-mode:
-debug-obfuscation-check:
-build-setup:
[echo] Resolving Build Target for MyFirstApp...
[gettarget] Project Target: Android 4.1
[gettarget] API level: 16
[gettarget] WARNING: No minSdkVersion value set. Application will install on all Android versions.
[echo] ----------
[echo] Creating output directories if needed...
[mkdir] Created dir: /home/banxi1988/work/cmd_dev_android/MyFirstApp/bin/res
[mkdir] Created dir: /home/banxi1988/work/cmd_dev_android/MyFirstApp/gen
[mkdir] Created dir: /home/banxi1988/work/cmd_dev_android/MyFirstApp/bin/classes
[echo] ----------
[echo] Resolving Dependencies for MyFirstApp...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
[dependency] API<=15: Adding annotations.jar to the classpath.
[echo] ----------
[echo] Building Libraries with 'debug'...
[subant] No sub-builds to iterate on
-pre-build:
-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
[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] Generating resource IDs...
[echo] ----------
[echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.
-pre-compile:
-compile:
[javac] Compiling 3 source files to /home/banxi1988/work/cmd_dev_android/MyFirstApp/bin/classes
-post-compile:
-obfuscate:
-dex:
[dex] Converting compiled files and external libraries into /home/banxi1988/work/cmd_dev_android/MyFirstApp/bin/classes.dex...
-crunch:
[crunch] Crunching PNG Files in source dir: /home/banxi1988/work/cmd_dev_android/MyFirstApp/res
[crunch] To destination dir: /home/banxi1988/work/cmd_dev_android/MyFirstApp/bin/res
[crunch] Processing image to cache: /home/banxi1988/work/cmd_dev_android/MyFirstApp/res/drawable-hdpi/ic_launcher.png => /home/banxi1988/work/cmd_dev_android/MyFirstApp/bin/res/drawable-hdpi/ic_launcher.png
[crunch] (processed image to cache entry /home/banxi1988/work/cmd_dev_android/MyFirstApp/bin/res/drawable-hdpi/ic_launcher.png: 87% size of source)
[crunch] Processing image to cache: /home/banxi1988/work/cmd_dev_android/MyFirstApp/res/drawable-ldpi/ic_launcher.png => /home/banxi1988/work/cmd_dev_android/MyFirstApp/bin/res/drawable-ldpi/ic_launcher.png
[crunch] (processed image to cache entry /home/banxi1988/work/cmd_dev_android/MyFirstApp/bin/res/drawable-ldpi/ic_launcher.png: 0% size of source)
[crunch] Processing image to cache: /home/banxi1988/work/cmd_dev_android/MyFirstApp/res/drawable-mdpi/ic_launcher.png => /home/banxi1988/work/cmd_dev_android/MyFirstApp/bin/res/drawable-mdpi/ic_launcher.png
[crunch] (processed image to cache entry /home/banxi1988/work/cmd_dev_android/MyFirstApp/bin/res/drawable-mdpi/ic_launcher.png: 78% size of source)
[crunch] Processing image to cache: /home/banxi1988/work/cmd_dev_android/MyFirstApp/res/drawable-xhdpi/ic_launcher.png => /home/banxi1988/work/cmd_dev_android/MyFirstApp/bin/res/drawable-xhdpi/ic_launcher.png
[crunch] (processed image to cache entry /home/banxi1988/work/cmd_dev_android/MyFirstApp/bin/res/drawable-xhdpi/ic_launcher.png: 85% size of source)
[crunch] Crunched 4 PNG files to update cache
-package-resources:
[aapt] Creating full resource package...
-package:
[apkbuilder] Current build type is different than previous build: forced apkbuilder run.
[apkbuilder] Creating MyFirstApp-debug-unaligned.apk and signing it with a debug key...
-post-package:
-do-debug:
[zipalign] Running zip align on final apk...
[echo] Debug Package: /home/banxi1988/work/cmd_dev_android/MyFirstApp/bin/MyFirstApp-debug.apk
[propertyfile] Creating new property file: /home/banxi1988/work/cmd_dev_android/MyFirstApp/bin/build.prop
[propertyfile] Updating property file: /home/banxi1988/work/cmd_dev_android/MyFirstApp/bin/build.prop
[propertyfile] Updating property file: /home/banxi1988/work/cmd_dev_android/MyFirstApp/bin/build.prop
[propertyfile] Updating property file: /home/banxi1988/work/cmd_dev_android/MyFirstApp/bin/build.prop
-post-build:
debug:
BUILD SUCCESSFUL
Total time: 5 seconds
上から参照:
http://developer.android.com/intl/zh-CN/training/basics/firstapp/index.html