Android basics 42: using internal (COM. Android. Internal) and hidden (@ hide) APIs-custom ADT

Source: Internet
Author: User
Tags printable characters

In the previous article, I talked about how to create a custom original-android.jar and create a custom Android platform to use a original-android.jar. This only allows you to use hidden APIs and leaves an obstacle for internal APIs: ADT. ADT defines a rule to prohibit the use of classes from Com. Android. Internal.


There are several ways to bypass this restriction rule:

1) Complete ADT source code can be downloaded. You can remove or modify the code, compile and install the new custom version ADT. The bad thing is that you must configure a 64-bit Linux system, download the source code, and compile it. This takes some time. When the new version of ADT comes out, you need to try again.

2) Another method is to modify the ADT bytecode. You only need to replace the "com/Android/inter/**" string with other strings, such as "com/Android/internax ".

The second method can be automated through scripts, and can work in windows without accessing the source code. This is why I have explained the second method in this article.

Modify the ADT bytecode

Go to your eclipse plugins folder and find the file named com. Android. Ide. Eclipse. ADT _ *. jar. Make a backup (to prevent modification errors) and copy a file to a separate "experimental" folder, where you can modify the bytecode.

Modify *. jar to *. Zip and decompress the file to a separate folder. What I get is as follows:

Go to the COM/Android/IDE/Eclipse/ADT/Internal/Project subdirectory to find the androidclasspathcontainerinitializer. Class file.


This file contains the string "com/Android/Internal/**". The next step is to replace the string with other strings, such as "com/Android/internax /**". Changing the length of a string may be fine, but it is best to replace only one letter to keep the length the same.

I replaced it with notepad ++ because it supports non-printable characters and does not modify non-printable characters when editing printed characters.

After modification, save the file and zip the folder. The file name is the same as the original version. Take my example: com.android.ide.eclipse.adt_8.0.1.v201012062107-82219.zip and rename it *. jar.

Note: Make sure that you compress the file correctly. You can compare the modified ZIP file with the original zip file's internal directory structure.

Delete the original ADT *. jar file in the eclipse plugins folder, copy the modified version, and restart eclipse.

If no problem exists, it is shown in:

Summary:
  1. Stop eclipse
  2. Obtain the JAR file of the ADT plug-in from the eclipse plugins folder.
  3. Rename .jaras .zip and decompress it to a separate directory.
  4. Find COM/Android/IDE/Eclipse/ADT/Internal/project/androidclasspathcontainerinitializer. Class
  5. Replace the string "com/Android/Internal/**" with "com/Android/internax /**"
  6. Zip compression of all files
  7. Rename. Zip to. Jar
  8. Replace the original adt jar file in the eclipse plugins folder with the modified version
  9. Start eclipse.

References:

Using Internal (COM. Android. Internal) and hidden (@ hide) APIs [Part 1, custom ADT]

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.