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

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

refer to

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



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

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




[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] ------------------
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

[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.


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



      [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] 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

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

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


 [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



Total time: 2 seconds