Summary of 12 errors in developing Android applets with Eclipse

Y2J
Release: 2017-05-03 11:48:29
Original
2505 people have browsed it

I encountered some small problems when developing Android small programs with Eclipse. In the process of learning, I will record the problems encountered. It is quite complicated, including program errors, Linux applications, eclipse settings, etc. ~

1. ERROR: Application requires API version 10. Device API version is 8 Solution: Modify two configuration files 1: In AndroidManifest.xml, Find this line. This line indicates the minimum version required to run this application. Change the number to the version on the simulator. (Device API) 2: In default.properties, target=android-8, change the target to the version to run the emulator and it will be OK. (application requires API)

2. Android requires compiler compliance level 5.0. Please fix project properties. Error Solution: 1. Right-click the project->android tools ->Fix Project 2. If not, check Project -> Properties->Java Compiler to confirm that JDK compliance is set to 1.6, and enable specific seeings.

3. Download In the .java file, the comments are basically in Chinese. In Linux, the Chinese part is garbled. The encoding of Chinese under Windows is generally gbk, while the encoding of Chinese under Linux is generally utf8, so it can be opened normally under Windows. The files are likely to be garbled under Linux. Solution: Use the iconv command to convert the file content encoding. For example, I have a file "Common Linux Commands" that opens normally under Windows, but will be garbled when opened under Linux. The method is to enter in the terminal: iconv -f gbk -t utf8 Common Linux Commands.txt > Common Linux Commands_cn .txt and then open the file "Linux Common Commands_cn.txt", the garbled problem of the file will be solved.

4. Exlipse three methods to display line number Solution: 1.Ctrl+f10 to display the menu and check the show line number option; 2. In the code editing area Right-click on the far left (that is, where the line number should be displayed), and the shortcut menu that appears is as shown in Solution 1; 3. Click Window (or right-click in the code editing area) ->Preferences->Gerenal->Editors-> ;Text Editors, then check the show line number check box

5. Install eclipse under windows and set the java jdk environment variable

1. The eclipse download address is www.eclipse. org/downloads/, find the download that matches the system you are using, and then unzip it

java jdk download address www.oracle.com/technetwork/java/javase/downloads/index.html

2. Configuration of java jdk environment variables: To put it simply, you need to set path and classpath. Bin must be added to path, and lib must be added to classpath.

My Computer->Properties->Advanced System Configuration.

1) It is already available in the path system. Just add the bin address in it and separate each path with;.

For example: C:\Program Files\Java\jdk1.6.0\bin

2) You need to create a new classpath yourself. Of course, if it already exists, you can just edit it in it. Pay attention to the classpath in front of it. There is .; represents the current path.

For example: .;C:\Program Files\Java\jdk1.6.0\lib\dt.jar;C:\Program Files\Java\jdk1.6.0\lib\tools.jar

3) In order to facilitate writing and future changes, you can set the java_home variable to C:\Program Files\Java\jdk1.6.0, so that %java_home% can be used to replace C:\Program Files in path and classpath. \Java\jdk1.6.0

For example: path can be set to %java_home%\bin

6. Configure the environment and run eclipse and Failed to load the JNI shared appears. library jvm.dll error

Solution: The windows used is 64-bit, and the 64-bit eclipse is downloaded, but the java sdk downloaded is 32-bit, which is a mistake. . . Change to 64-bit~

7. ANT environment variable settings

There are two main environment variables used by ANT under Windows, ANT_HOME, PATH.

Set ANT_HOME to point to the ant installation directory.

Setting method: ANT_HOME = D:\apache_ant_1.7.0

Add %ANT_HOME%\bin; %ANT_HOME%\lib to the path of the environment variable.

Setting method: PATH = %ANT_HOME%\bin; %ANT_HOME%\lib

8. Expected to find it in D:\jre6\lib\tools. jar

After typing the ant command on the command line, it prompts: "Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar"; the ANT_HOME environment variable has been configured; Solution: Copy the tools.jar file in the "C:\Program Files\Java\jdk1.6.0_16\lib" directory to the "C:\Program Files\Java\jre6\lib" directory, and rerun the command ant. It runs normally. problem solved.

9. Test run failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'

JUnit is not introduced, check whether it is in the configuration JUnit is checked. Project -> Properties -> Java Build Path -> Order and Export and check JUnit if it is unchecked.

10. Test run failed: Instrumentation run failed due to 'java.lang.ClassCastException'

Delete the package and develop the project package and Delete all test packages and reinstall them! ! !

11. After installing ADT and Android SDK, there are no two icons of Android SDK Manager and Android virtual Device Manager

##Eclipse - >window->customize Perpective->Command Groups Availability Check the andorid option

12. error: Error: No resource found that matches the given name (at ' background' with value '@drawable/btn_title_back_big').

The error shows that basically all resource files have errors. Right-click on the console, select preferences, and set the console buffer size to be large enough. By adding a 0, you can see which resource file is wrong and correct it.

The above is the detailed content of Summary of 12 errors in developing Android applets with Eclipse. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template