The introduction
The first time to see my article friends, you can focus on like, every day to share a variety of dry technology and programming monkey fun
Before you start your Android development journey, first set up the environment and then create a simple HelloWorld. The topics of this article are as follows:
- 1. Environment construction
- 1.1. JDK installation
- 1.2. Eclipse installation
- 1.3 Android SDK installation
- 1.4 ADT installation
- 1.5. Create AVD
- 2, the HelloWorld
1. Environment construction
1.1. JDK installation
If you don’t already have the JDK, you can download it here, and the rest of the work is step-by-step installation prompts. To set environment variables, perform the following steps:
- Add the following environment variables to my Computer -> Properties -> Advanced -> Environment Variables -> System Variables:
- The JAVA_HOME value is: D: Program Files\Java\jdk1.6.0_18 (the directory where you installed the JDK)
- The value of CLASSPATH is. %JAVA_HOME%\lib\tools.jar; %JAVA_HOME%\lib\dt.jar; %JAVA_HOME%\bin;
- Path: append %JAVA_HOME%\bin at the beginning;
- NOTE: Setting environment variables in the preceding four steps is not necessary to build the Android development environment, you can skip it.
After the installation is complete, you can check whether the JDK was successfully installed. Open the CMD window and enter Java – version to view the JDK version information. If a screen similar to the following appears, the installation is successful:
1.2. Eclipse installation
If you haven’t Eclipse, you can go to http://www.eclipse.org/downloads/ to download, download the Eclipse IDE for Java Developers as shown in the figure below (92 m) win the 32 bit version:
After decompressing, it can be used.
1.3 Android SDK installation
Download Android-sdk_R05-windows. zip at Android Developers, and decompress it to any path.
- Run SDK setup.exe and click Available Packages. If no installable package appears, click Settings and select “Force https://…” in Misc. For this, click On Available Packages.
- Select the SDK and its documentation or other packages you want to Install, and click Installation Selected, Accept All, Install Accepted to download and Install the Selected packages
- Create a new PATH in the user variable and set it to the absolute PATH of the tools in the Android SDK (local: D:\AndroidDevelop\ android-sdK-windows \tools).
When ok, restart the computer. After the computer restarts, go to the CMD command window and check whether the SDK is successfully installed. If the following output is displayed when you run Android -h, the installation is successful:
1.4 ADT installation
- Open the Eclipse IDE and go to the “Help” -> “Install New Software” menu.
- Click the Add… Button, the pop-up dialog required to enter the Name and Location: whatever Name himself, the Location type http://dl-ssl.google.com/android/eclipse. As shown below:
- After making sure to return, select the ADT we just added from the drop-down list after Work with, we will see Developer Tools below, expand it to include Android DDMS and Android Development Tool, check them. As shown below:
- Then follow the prompts step by step next.
After completion:
- Select Window > Preferences…
- Select Android in the left pane and click Browse on the right… D:\AndroidDevelop\ Android-sdK-Windows
- Click Apply, OK. The configuration is complete.
1.5. Create AVD
In order for Android applications to run on the emulator, you must create an AVD.
- 1. In Eclipse. Choose Windows > Android SDK and AVD Manager
- 2. Click Virtual Devices on the left panel, and then click New on the right
- 3. Fill in Name, select Target API, SD Card size is arbitrary, Skin is arbitrary, Hardware currently keep the default value
- 4. Click Create AVD to Create the AVD
Note: If you click Virtual Devices on the left panel and click New on the right, and there is no option in the Target drop-down list, then you:
- Click on the left panel of the Available Packages, in the right side of the check https://dl-ssl.google.com/android/repository/repository.xml, as shown in the figure below:
- Then click the Install Selected button and follow the instructions
The reason for these two steps is that some of the necessary Available Packages are not installed in the 1.3 Android SDK installation.
2, the HelloWorld
- Create a New Project” Android Project” from File -> New -> Project.
- Then fill in the necessary parameters as shown in the image below :(note that I checked Google APIs here, you can choose what you like, but you need to create the appropriate AVD)
Description of related parameters:
Project Name: The Name of the folder containing the Project. Following the JAVA specification, it is important to use the Package Name to distinguish different classes. I used helloWorld.test. Activity Name: This is the Name of the project’s main class, which will be a subclass of the Android Activity class. An Activity class is a simple class that starts and controls programs. It can create interfaces as needed, but not required. Application Name: An easy-to-read title on your Application. The “Use Default Location “option in the” Selection bar “allows you to select an existing item.
- After you click Finish, click on the Run menu of Eclipse and select Run Configurations…
- Select “Android Application” and click on the top left corner (the button looks like a piece of paper with a “+” sign) or double click “Android Application” to get a new option “New_configuration” (you can change it to whatever name you like).
- Click Browse in the right Android panel… , select the HelloWorld
- Select the appropriate AVD from Automatic in the Target panel. If no AVD is available, click Manager in the lower right corner… And then create a corresponding AVD. As shown below:
- Then click the “Run” button. If the operation is successful, the Android emulator interface will appear, as shown below: