安卓開發-培訓--命令行操方法

命令行操方法

Create a Project with Command Line Tools  

  1. Change directories into the Android SDK’s tools/ path.
  2. Execute:
    android list targets

    This prints a list of the available Android platforms that you’ve downloaded for your SDK. Find the platform against which you want to compile your app. Make a note of the target id. We recommend that you select the highest version possible. You can still build your app to support older versions, but setting the build target to the latest version allows you to optimize your app for the latest devices.

    If you don't see any targets listed, you need to install some using the Android SDK Manager tool. SeeAdding Platforms and Packages.

  3. Execute:
    android create project --target <target-id> --name MyFirstApp \
    --path <path-to-workspace>/MyFirstApp --activity MainActivity \
    --package com.example.myfirstapp
    

    Replace <target-id> with an id from the list of targets (from the previous step) and replace <path-to-workspace> with the location in which you want to save your Android projects.

Your Android project is now set up with several default configurations and you’re ready to begin building the app. Continue to the next lesson.

Tip: Add the platform-tools/ as well as the tools/ directory to your PATH environment variable.。


Running Your App


Run your app from a command line:

  1. Change directories to the root of your Android project and execute:(這步出錯,提示沒有ant 命令,省去執行下一步正常)
    ant debug
  2. Make sure the Android SDK platform-tools/ directory is included in your PATH environment variable, then execute:
    adb install bin/MyFirstApp-debug.apk
  3. On your device, locate MyFirstActivity and open it.



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章