If you follow the translation in the previous section, you will have a helloworld project.
This article describes how to install an android program device or simulator, which can be implemented by using eclipse and command line ..
Note that these files and directories are missing:
-
AndroidManifest.xml
-
This configuration List defines some basic program features and its components ..
<uses-sdk>
Element: You can use
android:minSdkVersion
Andandroid:targetSdkVersion
Attribute makes your app compatible with different versions.
For example:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" ... > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> ...</manifest>
Tryandroid:targetSdkVersion
Set high point and test well.
-
src/
-
Main Program Files
-
res/
-
Resource Folder:
-
drawable-hdpi/
-
Some image resources can be stored in the assets folder.
-
layout/
-
Layout XML file.
-
values/
-
For example, color definition and resource index.
This program is simple, but helloworld is the best entry.
Run on a real machine
If you have an Android device, you can install your program as follows:
- Connect the USB data cable and install the relevant USB driver.
- Enable the debugging mode of the mobile phone.
In eclipse:
- Open the project and click Run.Run.
- ClickAndroid Application.
Run the following command line:
- Change the directory to the project:
ant debug
- Make sure that the android SDK
platform-tools/
Directory inPATH
Environment variables, and then:adb install bin/MyFirstApp-debug.apk
- Find and run your program.
This is how to run your android program.
Run on Simulator
The simulator AVD is very useful. It can simulate many devices that do not have resolution.
Figure 1. The AVD manager showing a few virtual devices.
Create a simulator AVD:
- Open the AVD Manager:
- Click here in eclipse.
- Enter
<sdk>/tools/
:android avd
- ClickNew.
- Enter the basic information, such as the name, platform, SD card size, and resolution.
- PointCreate AVD.
- Select an AVD and start.
- Unlock the simulator after running it.
In eclipse, open the app to the simulator:
- ClickRun.
- InRunSelectAndroid ApplicationClickOK.
The command luggage is installed as follows:
- Change the path to the project:
ant debug
- Make sure the SDK
platform-tools/
The directory is in yourPATH
Environment variables:adb install bin/MyFirstApp-debug.apk
- Find it in the simulator and run it.