1.2.1 Use Eclipse + ADT + SDK to develop Android APP
1 Introduction
Here we have two options, directly use the packaged ADT Bundle for Android development, or configure it yourself because Google has given up the ADT update, and the official website has also canceled the download link. Here is the latest version before Google gave up the update Version ADT Bundle for everyone to download!
2. Use packaged Eclipse directly
32-bit version: adt-bundle-windows-x86-20140702.zip (Baidu network disk) 64-bit version: adt-bundle-windows-x86_64-20140702.zip (Google address) download and decompress, then skip directly to 4. to create A Helloworld project!
3. Configure Eclipse + ADT + SDK by yourself
Eclipse can be downloaded from Eclipse official website: Eclipse official download and SDK and ADT can be downloaded from AndroidDevTools: AndroidDevTools official website provides us with a lot of tools related to Android development, and there is no need to surf the Internet scientifically, a must-have development website! Be sure to mark! There may be some problems between different version configurations! The author uses an old version (very old), and you can download it if you need it: Eclipse: eclipse-jee-helios-win32.zip ADT: ADT-15.0.0.zip SDK: android-sdk-windows.rarBuilding process : 1. Decompress Eclipse: Find eclipse.exe in the decompressed folder and run it. After running, set the storage location of the project code (workspace) 2. ADT configuration: Click the menu bar in turn: help -> Install new software -> Add - > Local... -> Select the folder where you downloaded the pressurized ADT -> accept -> restart Eclipse -> see if the Android icon appears in the menu bar
If it appears, it means that the installation is complete PS : there may be a warning during the period, just ignore~ 3. SDK decompression configuration: Click the menu bar in turn: windows -> Rreferences -> Android -> select the decompressed SDK package -> OK -> open and re-authenticate 4 .Create AVD (Android Emulator): Click on the menu bar in turn: small phone icon -> New -> select system version -> Skin screen resolution -> set SD card size -> finish -> start ! PS: It may be very slow to start AVD for the first time, you need to wait~
4. Create and run the first program HelloWorld project
1. New -> Android App Project If you can't find it, you can go to Other -> android to find it, it's the same:
2. Then enter the project information in sequence:
3. Run the created program
4. See the running effect from the simulator:
5. Project directory structure analysis
First look at our project catalog map:
The next part we need to know:
- src directory: Contains all the program code files required by the App, where we write our Java code most of the time
- gen directory: only pay attention to the R.java file, which is automatically generated by ADT, which defines an R class, which can be regarded as a dictionary of id (resource number), including the id of resources such as user interface, graphics, and strings , and the resources we usually use are also called through R files, and the compiler will also look at this resource list, and unused resources will not be compiled in, which can save space for the App
- assets directory: store resources, and will not generate resource ids under the R.java file, you need to use the AssetsManager class to access
- libs directory: Store some jar packages, such as v4, v7 compatibility packages, or some third-party packages
- res resource directory: stores resources, drawable: stores image resources; layout: stores interface layout files, all of which are XML files; values: contains description files using XML format parameters, such as string.xml string, color.xml color , style.xml style style, etc.
- AndroidManifest.xml configuration file: the control file of the system, which is used to tell some basic information contained in the Android system App, such as components, resources, and required permissions, as well as the minimum version of the compatible SDK, etc.
6. Several commonly used views
Click: Windows -> show view on the menu bar to open the corresponding view:
Click other, the following are some commonly used views in Android:
In fact, the main thing is the use of Logcat, because unlike Java, our App runs on a virtual machine, but our console does not display relevant information, only the installation status, so we will check the program running on Logcat Log information:
7. Summary of this section
In this section, we have learned how to use Eclipse to build our Android development environment, the lazy version and the hands-on version, both are available; then we introduce some information about the directory structure of the Android project developed by Eclipse, in the next section we will Go deep into the HelloWorld project and understand the code in it!