Problems in Android development and corresponding solutions (continuous update)

Source: Internet
Author: User

Recently the blog write less, and then have to update frequently.

------------------------------------------------------------

1.try Cath unexpected problems caused by abnormal anomalies.

This problem is put first because such a situation occurs in the project in the previous array, and it is easy to be unnoticed or forgotten, but its error is fatal.

In java/android development, when a function is called, this function throws an exception of type A, and it is natural that in the place of the call we will try: Catch this exception, and in the vast majority of cases, the catch exception is automatically prompted and generated by Eclispe, the function throws a exception, then the call to the local catch a, in fact, we would better have to catch a after the addition of a catch (Exception ex) {}. The reason for this is to prevent other types of exceptions that might be thrown because of some indeterminate problems.

The last time I met a new Jsonobject (), it was natural to catch jsonexception, without further catch Exception, In fact, because the parameter format is wrong after it throws the java.lang.NumberFormatException, step by step tracking code found in the source code can actually throw this exception situation, and not caught, directly will cause the app to crash. Remember from then on!

The Android Private libraries in the 2.Eclipse project is not automatically generated.

In general, in Android development, the jar packages referenced in the project are placed in the Libs in the project directory, and the introduction of the library will be placed in the Android dependencies, and the jar package placed in Libs will be automatically placed in the project's Android Private Libraries, if there is no automatic generation, after the clean project generally under the console will find the corresponding error prompt, correction can be. This can occur if the project references a different V4 Compatibility Pack.

"Android sdk:resolving Error Markers" has been appearing in the 3.Eclipse.

There are many descriptions on the internet and the corresponding tentative solutions, which I have seen recently, and failed to solve after trying various schemes. The final method is as follows:

Delete this file, Workspace/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi, and restart Eclipse.

4. Unsatisfiedlinkerror caused by so file directory: Findlibrary returned null problem.

In Android development, it is unavoidable to refer to external so files and set up a project that may need to reference several different external so files. Because different directories of so files in the introduction library may be different, the directory structure in the project Lib directory that is generated after the package is packaged is a collection of different external so file directories. May appear armabi/armeabi-v7a/x86/mips, etc., in general, Armabi should be there, when the files in these three directories may not be the same, in some specific models may appear as above error. The reason is that different models of CPU structure led to the search for different directories under the package, and because the external library different so file directory may be Armabi under a, b so file, and x86 may contain only a, at this time the solution is as follows:

Directly delete x86 and MIPS directory, only keep the Armabi directory, when there is no x86 directory, the corresponding model will naturally take the Armabi directory to search for the corresponding so file.

5.Can ' t create handler inside thread that have not called Looper.prepare.

The problem is also classic, because non-UI threads in Android cannot modify UI operations (except, strictly speaking, Surfaceview and Textureview), which is typically done in child threads such as Toast.maketext and other operations. Generally with the help of sub-threading and the main thread message communication mechanism to solve.

Common solutions such as:

1). Handler-message mode;

2). Activity.runonuithread (runnable) mode and so on.

Problems in Android development and corresponding solutions (continuous update)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.