Home  >  Article  >  WeChat Applet  >  Summary of problems encountered in developing Android applets with Eclipse

Summary of problems encountered in developing Android applets with Eclipse

高洛峰
高洛峰Original
2017-02-23 14:39:031754browse

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, which indicates the minimum version required to run this application, and 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 on the project ->android tools ->Fix Project 2. If not, check Project -> Properties->Java Compiler Confirm that JDK compliance is set to 1.6, and enable specific seeings.

3. In the downloaded .java file, the comments are basically in Chinese, and the Chinese part of Linux is garbled. Question: The encoding of Chinese under Windows is generally gbk, while the encoding of Chinese under Linux is generally utf8, so files that are opened normally under Windows 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 uses three methods to display line numbers. Solution: 1. Use ctrl+f10 to display the menu and check the show line number option; 2. Right-click on the leftmost side of the code editing area (that is, where the line number should be displayed). , the shortcut menu that appears is like solution 1; 3. Click Window (or right-click in the code editing area)->Preferences->Gerenal->Editors->Text Editors, and then click the show line number check box Just check the box

5. Install eclipse and java jdk environment variable settings under windows

1. Eclipse download address http://www.eclipse.org/downloads/, find the one that matches yours Download the one that matches the system you are using, and then unzip it

Java jdk download address http://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 a Failed to load the JNI shared library jvm.dll error occurs when running eclipse

Solution: The windows I use is 64-bit, and I downloaded 64-bit eclipse, but the java sdk I 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 and 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: Change " Copy the tools.jar file in the directory "C:\Program Files\Java\jdk1.6.0_16\lib" to the directory "C:\Program Files\Java\jre6\lib" and rerun the command ant. It runs normally and the problem is solved. .

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

JUnit is not introduced, check whether JUnit is checked in the configuration. 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, delete the development project package and test package, and reinstall it! ! !

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

Eclipse ->window->customize Perpective->Command Groups Availability check Select 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 displays basically all resource files If all errors occur, right-click on the console and select preferences. If the console buffer size is set large enough, you can add 0. Then you can see which resource file has the error and correct it.

For more related articles on the summary of problems encountered in developing Android applets with Eclipse, please pay attention to the PHP Chinese website!

Statement:
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