Use internal (COM. Android. Internal) and hidden (@ hide) APIs-Part 4

Source: Internet
Author: User
Tags printable characters

Xirihanlin 2011.06.07

Original path: http://devmaze.wordpress.com/2011/01/18/using-com-android-internal-part-4-customizing-adt/

In the previous articleArticleI described how to create a custom original-android.jar and how to create a custom Android platform to use this original-android.jar. This is sufficient for the hidden API. But for internal API, there is still a burden: the ADT plug-in of Eclipse. It limits the use of any class in the com. Android. Internal Package.

There are several ways to solve this access restriction.

1) The ADT source code can be downloaded. Therefore, delete/modifyCodeTo compile a new ADT. The trouble is that you need to build a 64-bit Linux system, download the source code, compile and so on. It takes some time. When a new ADT version is available, you need to repeat it.

2) The other method is to modify the ADT bytecode. Replace "com/Android/Internal/**" with a string similar to "com/Android/internax /**".

The second method can be implemented using scripts. You do not need to access the source code or operate on Windows. This is why I chose the second solution in this article.

ModifyADTByte Code

Go to the eclipse plugins folder. Find the file name that looks like "com. Android. Ide. Eclipse. ADT _ *. Jar. Back up this file (to prevent errors in the middle ). Copy the file to an "experimental" folder. Here, we need to modify its bytecode.

Rename *. jar to *. Zip. Decompress the file to a separate folder. Refer to take a film:

Now, go to the COM/Android/IDE/Eclipse/ADT/Internal/Project Sub-folder.

Find the androidclasspathcontainerinitializer. Class file.

This file contains the "com/Android/Internal/**" string. The next step is to replace this string, for example, "com/Android/internax /**". It is theoretically safe to change the length of a string, but it is best to replace one of the letters with the same length.

I used notepad ++ to modify it. It supports non-printable characters. Therefore, when modifying it, do not touch and modify non-printable characters.

After this is done, save the file. Compress this folder to ensure that the file name is the same as the original file. Here, the file name is com.android.ide.eclipse.adt_8.0.1.v201012062107-82219.zip.

Note: ensure the correctness of the compressed file. Compare the original file and modify the root file structure of the file.

Now, replace the *. jar file of the original ADT with the modified version. Then, start eclipse.

In the use of the library window, you should see the following, everything has become so beautiful:

Summary

1. Disable eclipse

2. Copy the JAR file of the ADT plug-in from the eclipse plugin folder.

3. Rename. jar->. Zip and decompress it to a separate folder.

4. FindCOM/Android/IDE/Eclipse/ADT/Internal/project/androidclasspathcontainerinitializer. ClassFile

5. Replace "com/Android/internax/**" with "com/Android/Internal /**"

6. Compress this folder

7. Rename. Zip->. Jar

8. Replace the original adt jar file with the modified JAR file.

9. Start eclipse

Conclusion

This is the last step to use the internal API without reflection.

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.