How to debug the Android app on Eclipse

Source: Internet
Author: User

There are often many errors when importing an Android app project. Taking the built-in alarmclock as an example, many errors often occur after eclipse is imported, as shown in:

 

For example, intent. action_alarm_changed in cannot be accessed.Source codeSee why?

According to Java programming specifications, we know that this API (static variable) is hidden, so it cannot be used in the SDK. After knowing the cause, we have several solutions (recommended method 2 ):

1. Change the sourceCodeRemove @ hide, and then compile an SDK to replace the default SDK.
In Linux, use the make product-SDK command to compile a new SDK. Note that after compilation, we do not need the entire SDK. We only need android. JAR file to replace android. jar, for example, the directory corresponding to the jar in the author's SDK is:
F:/program files/Android-SDK-Windows/platforms/Android-8/Android. Jar
To compile the SDK, run the make product-SDK command in the Linux compiling environment. After the SDK is successfully compiled, the following message is displayed:
Package SDK: Out/host/linux-x86/SDK/android-sdk_eng.stevewang_linux-x86.zip
In the Linux compiling environmentOut/host/linux-x86/SDK/android-sdk_eng.stevewang_linux-x86/platforms/Android-2.2/Directory.Android. JarFile. Use this file to replace F:/program files/Android-SDK-Windows/platforms/Android-8/Android. jar. Remember to back up before replacement
This method is troublesome. method 2 is recommended.

2. Add the class. jar file compiled by the framework to the build path of Eclipse.
In fact, when compiling Android, we compiled the framework into a temporary jar package. The path of this jar package is generally:
Out/target/common/obj/java_libraries/framework_intermediates/classes. Jar
[Font = 'dejavu] You only need to use the make command in the android source code directory on Linux to generate this file.
[Font = 'dejavu]
[Font = 'dejavu] Because the APIs in the jar file have not been repackaged, the APIs that have been replaced by @ hide are not removed. So we can still reference
[Font = 'dejavu] @ hide API. The android. jar file in the SDK is repackaged and generated, and the @ hide API marked in it has been removed.
[Font = 'dejavu ]. Out/target/common/obj/java_libraries/framework_intermediates/classes. jar is copied to the local PC.
Then add the jar package to the project.
Specific Method:
1. Copy out/target/common/obj/java_libraries/framework_intermediates/classes. Jar generated by Linux compilation to the local PC.
2. In the android project of Eclipse, choose project properties-> JAVA build path-> libraries-> Add library-> User library-> next-> userlibraries to go to the user libraries management page, and click New to create a user library, for example, android_framework, click Add jars to add the jar package to the created user library, and then click OK.
3. Select Project Properties> JAVA build path> order and export to move the created user libraries to the android SDK.

For example:

Then our engineering error disappears:

This problem is basically solved.

Reproduced from: http://www.bangchui.org/read.php? Tid = 274

Related Article

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.