Eclipse builds Android environment
Directory
First, install the JDK. 1
1. JDK Download ... 1
2. Install the JDK. 1
3. Environment variable setting ... 3
Second, install Eclipse. 5
1. Eclipse Download ... 5
2. Eclipse installation ... 5
Third, install the SDK. 5
1. Download the SDK. 5
2. SDK installation ... 5
3. SDK configuration ... 8
Iv. Configuring ADT: 11
V. Create simulator (AVD) ... 13
Vi. HelloWorld Procedures ... 16
1. Create Android Project 16
2. Create AVD device ... 18
3. Compile and run the program ... 19
4. Debugging program ... 20
Seven, import an existing project ... 23
Import non-Android engineering method: ... 23
Import Android Engineering Method: ... 23
Eight, install apk software ... 23
1. Install apk software on simulator ... 23
2. Uninstall APK software on simulator ... 25
3. Install apk software on the real machine
4. Uninstall APK software on the real machine
First, install the JDK
1. JDK Download
Open the Site http://java.sun.com, click on the right side of "Java SE", appear in Figure 1-1, click "JDK Download" that is (https://cds.sun.com/is-bin/INTERSHOP.enfinity/ wfs/cds-cds_developer-site/en_us/-/usd/ viewfilteredproducts-singlevariationtypefilter) Download Jdk-6u23-windows-i586.exe.
Figure 1-1 Java se download page
2. Installing the JDK
Double-click Jdk-6u21-windows-i586.exe to get the 1-2 interface.
Figure 1-2 Java SDK Setup Interface
Click "Next", Change and confirm the installation path (D:\Java\jdk1.6.0_21\, please note that if you change the path after adding java\jdk1.6.0_21\, to prevent the installation file and D-drive file Mix), click "Next".
Figure 1-3 Java target Folder Installation interface
After changing the path, click Next and then finish.
3. Environment variable Setting
XP: "My Computer" à right-click Property à "advanced" à "environment variable" à system variable (WIN7: "My Computer" à right-click Property à "advanced system settings" à "advanced" à "environment variable" à system variable).
Set the following three properties and their values:
Java_home:d:\program files\java\jdk1.6.0_21
Point to the JDK installation path, under which you should be able to find the bin, Lib, and so on. The installation path of the JDK can select any disk directory, but the recommended directory hierarchy is slightly lighter.
Path:%java_home%\bin;%java_home%\jre\bin
The bin directory that points to the JDK, which holds a variety of compiled execution commands, allows the system to identify Java commands under any path, and does not need to type a large string of paths when the console compiles, otherwise the Java program will be moved to the%java_ class file each time it is run. Home%\bin directory, and then open dos to change the path below the path to execute the class file.
Since the JDK is installed, there are two virtual machines (JRE and JRE under the JDK) in this directory, so you need to include the Bin folder under two virtual machines.
If you do not add "jdk1.6.0_21\bin" in Path, you will see the situation shown in Figure 1-4:
Figure 1-4 Javac problem
Classpath:.; %java_home%\lib\dt.jar;
A class file search path to the Java program compile runtime, which tells the JVM what path to use or execute on, and facilitates the JVM to load the class file to allow the user to import *, ".;" Indicates that the compile runtime looks for the current directory's class file, the Dt.jar function is to run the Environment Class Library, provides support for the Java Swing build display, can be opened with WinRAR look, jar and zip format, but the extension is different The Tools.jar function is to provide a non-core class of Tool class libraries and utilities, and LIB provides development tools to use files.
Open "Start" à "run", enter "cmd", into the DOS system interface. Then enter "Javac", if the installation is successful, the system will display a series of parameters about the Javac command and usage.
Special Note: Java_home cannot be appended with ";", and note that the pathname is the path to the JDK, not the JRE, and the variable name is case-insensitive.
Added: Dt.jar, Rt.jar, Tools.jar
Dt.jar and Tools.jar are the two most basic Java packages, which contain the most important Lang packet in Java to a variety of advanced functions such as the visual swing package, Java is essential.
Jar Package |
Category |
Remark description |
Tools.jar |
Tool class library, compile and run the classes that need them sun.tools.java.*,sun.tools.javac.* |
Generally only used in Javac, Java Xxx.java equivalent to Java–classpath=%java_home%/lib/tools.jar XX. Xxx.main Xxx.java,javac is the encapsulation of the above command, so it is not added to the classpath. The application server is used to compile the JSP file, the application server will load itself, do not need to set itself. |
Rt.jar |
Java Base Class Library |
The default is in the root classloader loading path, no need to add to Classpath, the same jre/lib most of the jar is in this path, detection method: Delete Classpath Rt.jar, with java–verbose command detection. |
Dt.jar |
The class library that runs the environment, mainly the swing package |
When using swing, it's best to add that the Eclipse development environment defaults to the JRE, so it needs to be set. |
Reference resources:
Effect of 3 jar packages: http://blog.csdn.net/hlw881008/article/details/5505251
Eclipse See the role of 3 packages: http://blog.csdn.net/dy_paradise/article/details/3909212
The role of the JDK folders: http://blog.csdn.net/qcontriver/archive/2010/03/09/5360975.aspx
Second, install Eclipse1, eclipse download
To open the official website www.eclipse.org, click Downloads and select the eclipse Classic 3.6.1 download under Windows, which is http://www.eclipse.org/downloads/ Download.php?file=/eclipse/downloads/drops/r-3.6.1-201009090800/eclipse-sdk-3.6.1-win32.zip. Download to d:\.
2. Eclipse Installation
Unzip the downloaded ZIP archive and create a shortcut to the desktop (right-click Chart à "eclipse.exe" to "à" desktop Shortcut ") to facilitate startup.
Note: The SDK is like Java Jdk,adt is just an Eclipse plug-in, so the installation order of the two is not strictly required.
Third, install the SDK1, download the SDK
Open website http://www.onlinedown.net/softdown/32289_2.htm download Android-sdk_r08-windows.zip, and unzip to D:\Android.
2. SDK Installation
Run the SDK Manager.exe in the folder D:\Android\android-sdk_r08-windows\android-sdk-windows, in Figure 3-1, select the file you want to install, then "Install", The time to wait for a long long.
Figure 3-1 SDK Installation Interface
If you encounter the error message "Failed to fetch URL ...", then you need to change the HTTPS mode to HTTP, select "Settings" on the left side of the "Android SDK and AVD Manager" window, select "Force HTTPS ://... "option, click" Save & Apply "and rerun SDK Setup.exe
I spent a lot of time here and later found out that some outdated files were downloaded, so I need to be careful. Click Available packages to select the higher version of the SDK.
Figure 3-2 Available Packages
Figure 3-3 Installed Packages
Note: In order to allow the user to reduce the long waiting time, here the downloaded directory is packaged into a compressed file, so that you can directly unzip the use without the need to perform the steps of the SDK installation. See the Android-sdk-windows.rar compression package in the software catalog.
After the installation, the file list is as follows: Some of these may be superfluous, online explanations:
Add-ons: Some extension libraries, such as Google APIs add-on
DOCS:API documents, etc.
Platforms: Platform components for each version
Samples: Some instance programs
Tools: A variety of assistive tools
Some USB drivers under the Usb_driver:windows
Temp: Holds temporary files during download platform components
3. SDK Configuration
Add the folder path for tools (my path is D:\Program files\android\android-sdk-windows\tools;) to the environment variable of path, in the same way that you set the environment variable method.
Please note: You must complete the installation of the Android SDK at this time to succeed, the following:
1) SDK location point to Android directory
The Android option in Windowàpreferences, the SDK location should be the installation path of the Android SDK (here is D:\Android\android-sdk-windows).
Add: If you are extracting the Android-sdk-windows.rar package directly during the SDK installation process, you need to configure the SDK before you can complete the installation of the SDK.
Figure 3-4 Android SDK Path configuration
If you do not set the value of the SDK location, a figure 3-5 error occurs.
Figure 3-5 SDK path error not added
2) Update the SDK in eclipse
"Window" à "Android SDK and AVD Manager" à "installed packages" à "Update all" à "Accept all" à "Install Accepted", see Figure 3-6. The total installation time is approximately 45 minutes, the ADB Restart dialog box appears, click Yes, and finally close the dialog box except Eclipse, when the ADT installation succeeds.
"Failed to fetch URL http://dl-ssl.google.com/android/repository/repository.xml" appears after "Install Accepted"
Search a lot of information, the method is as follows:
1) "Setting" on the left side of "Android SDK and AVD Manager", select "Force https://..." option;
2) deselect "Ask before restarting ADB4", save the settings, the SDK downloader, there is no "save and Apply", modify the settings after the tool automatically to the specified address download repository.xml (about save and There are a lot of useless posts, there are ways to add environment variables and press ENTER to save. The first time I made a revision. cannot be used, after modifying the configuration through the previous R05 version, the R06 downloader is used smoothly. )
3) If the connection is successful, then OK, the next step is to download the installation
Problem: There is no "Setting" option on the left, but practice has proved that this situation is not very problematic.
Select the package you want:
A. If you just try Android 2.0 Emulator (simulator), then you only select "SDK Platform Android 2.0." API 5, Revision 1 "is ready to install.
B. If you are developing applications and game apps on this SDK, you will need to accept and comply with all licensed Content (accept All)
Figure 3-6 SDK Update interface
If the SDK is not updated, the "an SDK Target must is specified" error will appear when you create Android project, 3-7.
Figure 3-7 An SDK Target must is specified interface
Iv. Configuration of ADT
Open Eclipse,help->install New Software Open Figure 4-1 dialog box
Figure 4-1 ADT Download URL settings
In "Location" to write Http://dl-ssl.google.com/android/eclipse, that is, according to the contents of the red box, and finally click OK, the figure 4-2 interface will appear, click "Select All", Change the key part of the red box to the same, click "Next>" under the different page two times, then select "I Accept the terms of license Agreement" and "Finish", then patiently wait about 20 minutes, let the system install Software, note that there may be "Security Warning" at this point, primarily that ADT contains unsigned content, and that it does not have validity and authenticity, ask whether to continue the installation, the relationship is not big, click "OK", and finally eclipse will prompt the restart for ADT to take effect, click "Restart Now" can be.
Figure 4-2 ADT Installation
V. Create a simulator (AVD)
Windowsàandroid SDK and AVD manageràvirtual devicesànew fill in Figure 5-1, and then click Create AVD.
Note: If you click Virtual Devices on the left panel and then click New on the right, and the target drop-down list is not available, click Available Packages on the left panel and tick https://on the right. Dl-ssl.google.com/android/repository/repository.xml, then click the Install Selected button, then follow the prompts.
Figure 5-1 Creating a new emulator
Explanation: Target is the available platform for the simulator, the SD card is the memory cards, that is, the cell phone card, the skin is the screen size of the simulator display, the specific parameters are:
wvga:800*480
qvga:320*240
vga:640*480
hvga:480*320
wqvga400:240*400
wqvga432:240*432
wvga800:800*480
wvga854:854*480
Alternatively, you can choose resolution to set the emulator screen size freely. Value in Hardware (special device required by AVD): abstracted LCD Density (resolution) its value is set automatically by the selected skin, and so on.
Figure 5-2 Running the emulator
With the SDK Android2.2 selected, Startàlaunch in the point, the emulator for Figure 3-3 will appear.
Figure 5-3 Starting the emulator
Figure 5-4 Unknown Virtual appliance
Android emulator error, Emulator:ERROR:unknown virtual device name
Cause: The default location of my document is changed because of the file path reference error created.
Law one: Copy the "f:\users\<username>\.android" file under "c:\users\<username>\.android" to solve this problem, But one obvious drawback to this solution is that if you create an AVD again, you have to replicate it again.
Law two: "My Computer" à right-click Property à "advanced" à "environment variable" à "system variable" à "new" variable named "Android_sdk_home" (note that this variable name cannot be changed, only this name!) ), then change the value of the variable to the location where you want to place the ". Android" folder where the AVD resides, for example: "F:\AndroidEmulator", where I put it in the Android SDK package with the value: "D:\Program files\android \android-sdk-windows "
Vi. HelloWorld Program 1, creating Android Project
"File" à "New" à "other" à "Android" à "Android Project" appears in Figure 3-1 interface, then fill in Project name, application name, package name, Create activity content, and select Build target.
which
Project name: A project that actually corresponds to a folder.
Build Target: Select the SDK version used by the application.
Application name: The names of the programs that are typically present in the application's title bar.
Pakcage Name: This name can theoretically be arbitrary, but Pakcage has a certain naming convention, that is: The first point specifies the type of organization, such as COM generally refers to the company, Org refers to the organization, EDU refers to the education part; The second point refers to the name of the organization, such as Sun, I used my own name. , the third and later can be defined according to their own classification.
Creak Activity:activity is a running entity of a andriod program, a bit similar to the C language main function, the difference is that the Android program can have multiple entities similar to the main function.
Min SDK Version: This item is generally corresponding to the build target one by one and does not need to be specifically noted.
Figure 6-1 New Android Project
2. Create an AVD device
See section Fifth. If the AVD device is not created, there is no relationship, you can right-click on the Project à "run as" à "run Configurations" à "Android Application" à "Android" (fill in the project name to be run) à "Target" (Set the deployment device's selection to Mannul to prevent confusion with multiple deployment devices) à "Run". Select "Launch a new Android Virtual Device" In the Popup dialog box, select the SDK, and click OK.
3. Compile and run the program
Open the Hello.java file with the content 6-2 shown:
Figure 6-2 Hello.java File contents
Figure 6-3 Java Build Path settings
Projectàproperties, appear in Figure 6-3 dialog box, put Android 2.2 tick on, click Ok;runàrun (ctrl+f11) àyesà Select SDK, click Startàlaunchàok, wait 2 minutes will appear figure 6-4 result interface , indicating success.
Note: Right-click the Java file you want to run à "run as" à "run Configurations" à "Android Application" à "Android" (fill in the project name that needs to be run) à "Target" (Set the deployment device's selection to Mannul to prevent confusion with multiple deployment devices) à "Run".
Figure 6-4 Running the result interface
Reference Source: http://blog.csdn.net/zhq56030207/archive/2010/08/31/5852130.aspx
4, debug program through DDMS to debug the program:
(1) Switch the Eclipse development tool's working interface to the Ddms tab. 6-5 and figure 6-6 are shown.
Figure 6-5 Opening the view layout display operation
Figure 6-6 View layout selection box
(2) Select the "Devices" tab in the "DDMS" screen to view its menu features: Debug process (Debug), update Threads (update thread), update heap (update heap), cause GC (cause garbage collection), Stop Process (Stop thread), screen Capture, reset adb (restart Android Debug Bridge) menu options.
Debug your program with DDMS "Logcat"
(1) "Logcat" uses the static method of the "Andrdoi.util.Log" class to find errors and print system log messages.
Andrdoi.util.Log commonly used methods have the following 5:
LOG.V (string tag, string msg); VERBOSE
LOG.D (string tag, string msg); DEBUG
LOG.I (string tag, string msg); INFO
LOG.W (string tag, string msg); WARN
LOG.E (string tag, string msg); ERROR, applicable to "breakpoint" mode debugger
LOG.V, LOG.D information should only exist in the development process, the final version can contain only log.i, LOG.W, log.e Three kinds of log information.
(2) Click "Run"--"Debug" menu command to enter the debug mode.
(3) Switch to the "DDMS" screen and click on the "Logcat" tab to view the log information we just printed in the program. Use different colors to indicate different levels of information, easy to follow the program.
(4) Debugging method
1) Set breakpoint, step: Double-click a row of the marker bar
2) declares a conditional breakpoint, triggering completion: The breakpoint is triggered when the expression value changes. Double-click the breakpoint after you have set the breakpoint, select "Breakpoint Properties" on the Tick "Enable", "Conditional", write the expression variable in the box, when satisfied, the program will hang, and when you enter the conditional expression, you can also use code help. In the context menu, the result is displayed by Ctrl+shift+i or right-clicking the variable and selecting inspect selection.
Figure 6-7 Setting up the Debug interface
Vii. Import an existing project to import non-Android engineering methods:
"File" à "import" à "general" à "Existing project into Workspace" à "Next" à "select root directory" à "Browse", select the location where you want to import the project.
Note: If you do not have an Android package, you will need to reset the "Build Path".
To import Android engineering methods:
"File" à "New" à "project" à "Android" à "Android Project" à "Next" à "Contents" à "project name" (another name) à "Create project from Existing source "à" location "à" Browse "(select the folder where the Android project is located, to the folder where the. xml resides) à" build Target "(choose Emulator Platform version) à" Finish ".
Install APK software 1, install APK software on simulator
First go to the folder where the Android SDK is located, because the simulator takes a few minutes to start, so we first use the command (EMULATOR-AVD Youravdname) Start the emulator (Note: double-clicking Emulator.exe under the Tools folder does not start), and then copy the files under Plantform-tools to tools under the Android SDK folder (if you have duplicate overlays, You can also add plantform-tools environment variable), then open "Run", enter cmd, click "OK", enter "adb install" and the APK to be executed into CMD to press ENTER, then the figure 8-1 interface will appear, success!
Figure 8-1 Command Prompt interface
Note: You must copy the files under Plantform-tools to tools or add the Plantform-tools path to the environment variable in path, because the ADB command is in plantform-tools and tools does not, So if this is not done, the error in Figure 8-2 will appear.
Figure 8-2 ' adb ' is not an internal or external command interface
If the APK file name contains Chinese, there will be a figure 8-3 error, only need to change Chinese to English and digital.
Figure 8-3 "Segmentation fault" error interface
Figure 8-4 APK Installation Effect interface
After the installation succeeds, the icon in the Red box appears on the emulator panel and is clicked to run.
2. Uninstall APK software on simulator
"Setting (the Setting icon in 8-4)" à "applications" (application) à "Manage applications" (Management application) à "waterwave" à "Uninstall" (uninstall) à "OK" (confirm). The "Waterwave" icon disappears on the uninstall Success panel at this time.
Figure 8-5 APK Uninstall succeeded
3. Install apk software on the real machine
First "set" à "application" à tick "unknown source" à "back" à "development" à tick "usb debugging".
Fayi
Download and install 91 mobile phone assistant for Android. Then connect your phone to your computer using USB and open 91 assistant 8-6.
Figure 8-6 91 Phone Assistant Start screen
"Manual connection" à "USB connection" à "? "À" system maintenance "à" file management "à" quick access "à" memory card "à" upload to the device "à" file "(select the. apk file to install)-double-click the. apk file you want to install, and the figure 8-7, click Install, Finish.
Figure 8-7 APK Installation Interface
Or, simply double-click the. apk to install it on your phone.
Law II
Download hiapk Installer (apk installer) on http://www.hiapk.com/bbs/thread-40417-1-1.html, double click to install (can only be installed on the computer), 8-8. This software will automatically link your apk program, just double-click the APK program can be automatically installed on the phone.
Figure 8-8 hiapk Installer installation Successful interface
Fahsarm
Install Astro (File Manager): Put astro.apk in the phone's SD, then in the phone's file Manager in the SD card in the midpoint of the apk file, then the panel will appear astro icon. When installing the software in the future, simply copy the. apk file to the SD card and you can install and uninstall the software on the APK installer on your phone.
Law IV
Download a built-in APK installer (http://www.liqucn.com/k/77002.shtml) for your phone, then copy the. apk file to your SD card and install it.
Add: File Manager features: File view, file management, file search, program uninstall and backup, process management, SD card status.
APK Installer: Simplify the process of installing the APK file so that it can be installed on your phone with the APK software.
Note: When the phone is connected to the computer, to download the drive or APK installer (commonly used is the pea clip, 91 Assistant), or just the phone's memory card connected to the computer, and the phone is not connected.
Eclipse builds Android Environment