Back

【Lesson 4】在真实手机上运行Android程序(开发者模式)(Run your app on a real device)

发布时间: 2014-09-21 12:18:00

refer to http://developer.android.com/training/basics/firstapp/running-app.html

1. 手机连到电脑上

2. 设置 -> 开发人员选项( developer options ) -> 调试 -> USB调试 是勾选的。  (在 Android 4.2 以上版本,在 设置  -> 关于手机中, 点按 build number 7 次)

然后,如果你用的是Eclipse, 直接  Run as -> Android Application . 

如果你跟我一样用的是command line:

    $ cd <project_folder>
    $ ant debug
就会开始编译项目啦
    然后 
    $ siwei@siwei-Lenovo-V470c:/workspace/test_hi_android$ adb install bin/HiSiwei-debug.apk 
* daemon not running. starting it now on port 5037 *
* daemon started successfully *

附: 下面是 ant的过程

siwei@siwei-Lenovo-V470c:/workspace/test_hi_android$ ant debug
siwei@siwei-Lenovo-V470c:/workspace/test_hi_android$ ant debug
Buildfile: /workspace/test_hi_android/build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 23.0.2
 [checkenv] Installed at /workspace/android-sdk-linux

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

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 20.0.0
     [echo] Resolving Build Target for HiSiwei...
[gettarget] Project Target:   Android 4.4.2
[gettarget] API level:        19
[gettarget] WARNING: No minSdkVersion value set. Application will install on all Android versions.
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: /workspace/test_hi_android/bin/rsObj
    [mkdir] Created dir: /workspace/test_hi_android/bin/rsLibs
     [echo] ----------
     [echo] Resolving Dependencies for HiSiwei...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency] 
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

-code-gen:
[mergemanifest] No changes in the AndroidManifest files.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Found new input file
     [aapt] Generating resource IDs...
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] No need to generate new BuildConfig.

-pre-compile:

-compile:
    [javac] Compiling 1 source file to /workspace/test_hi_android/bin/classes

-post-compile:

-obfuscate:

-dex:
      [dex] input: /workspace/test_hi_android/bin/classes
      [dex] Found modified input file
      [dex] Converting compiled files and external libraries into /workspace/test_hi_android/bin/classes.dex...

-crunch:
   [crunch] Crunching PNG Files in source dir: /workspace/test_hi_android/res
   [crunch] To destination dir: /workspace/test_hi_android/bin/res
   [crunch] Crunched 0 PNG files to update cache

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

-package:
[apkbuilder] Found modified input file
[apkbuilder] Creating HiSiwei-debug-unaligned.apk and signing it with a debug key...

-post-package:

-do-debug:
 [zipalign] Running zip align on final apk...
     [echo] Debug Package: /workspace/test_hi_android/bin/HiSiwei-debug.apk
[propertyfile] Updating property file: /workspace/test_hi_android/bin/build.prop
[propertyfile] Updating property file: /workspace/test_hi_android/bin/build.prop
[propertyfile] Updating property file: /workspace/test_hi_android/bin/build.prop
[propertyfile] Updating property file: /workspace/test_hi_android/bin/build.prop

-post-build:

debug:

BUILD SUCCESSFUL
Total time: 2 seconds

Back