Creating a new project
cd <android-sdk-dir>/tools android create project --target <target-id> --name <name-of-project> \ --path <path-where-you-want-to-keep-your-project> \ --activity <first-activity-name> \ --package <app-package-name>
For target-id do
android list targetsto see the available targets and select an id from them
Example:
android create project --target 1 --name MyFirstApp \ --path ~/Apps/MyFirstApp \ --activity MainActivity \ --package com.example.myfirstapp
Making changes
I use emacs to edit the java code generated, and the layout xml file main.xml. To test any non-Android-specific piece of functionality it is a good idea to try it out in a stand-alone .java file outside the project. I have done this for trying to do a http request and it has helped.Building the app (debug version)
cd <your-project-directory> PATH=<android-sdk-dir>tools:$PATH ant debug
Launching the app in your emulator or phone
Start up your emulator by opening the avd manager:<android-sdk-dir>/tools/android avd
Otherwise, plug in your phone and turn on USB debugging.
In your project directory, do:
<android-sdk-dir>/platform-tools/adb install bin/<app-name>-debug.apk <android-sdk-dir>/platform-tools/adb logcat
Your app is installed, run it and look at the logcat output running on your command-line to debug what went wrong. I am assuming you have put enough Log.d() messages in your app code.
After you're done, you can uninstall the app by doing
<android-sdk-dir>/platform-tools/adb uninstall <package-name>
where package name is that com.example.myfirstapp or something you gave while creating the project
Note: Google's documentation has all of this information - you just have to fish it out since their main focus seems to be Eclipse/Android Studio based development.
No comments:
Post a Comment