This article is translated from https://devmaze.wordpress.com/2011/01/18/using-com-android-internal-part-3-custom-android-platform/
In the previous article I showed how to create a custom original-android.jar that contains all the classes in the internal API and the hidden API.
The next step is obviously to modify the existing Android platform (Sdk_dir/platforms/platform-x/android.jar). You can simply replace Android.jar with the Original-android.jar created in part 2nd, but all of your projects have unrestricted access to internal APIs and hidden APIs. This is not a good fit, because in most projects you may not be allowed to do so. Also, you basically want to prohibit the use of these APIs (this is the default behavior of Adt/android.jar), but you need to use both internal and hidden APIs in a few projects.
To achieve this flexibility, a new custom Android platform needs to be created. When there is no need to use the internal and hidden APIs, you use the original Android platform. When you need to access the internal and hidden APIs, you use the custom Android platform.
Android SDK Directory tree
Let's see how the Android SDK is organized:
We need a "platforms" catalogue and look Inside:
Here is a list of supported Android platforms.
Now let's see how this relates to the eclipse settings. Select an Android project and right click on Android->properties. You can see a list of supported platforms (it reflects the .../platforms/folder). Here are the following:
Create a new platform
To create a custom platform, you need to copy the Android-9 folder, name it android-9-internals, and then make some changes:
- Remove Android.jar from the Android-9-internals folder.
- Copy the Original-android.jar and rename it to Android.jar.
- To modify the Build.prop file:
...
Ro.build.version.sdk=9–> ro.build.version.sdk=-9
...
Ro.build.version.release=2.3–> ro.build.version.release=2.3.extended
Restart Eclipse, confirm that you can see the new platform, and here's what I see:
Why would I choose API Level-9? That's because it must be a number and cannot be 9 (or any other API level that already exists), otherwise your custom platform will not be used (it will appear in the list but will not work and compile with the original same number of platforms).
The following is the libraries view (when the custom platform is selected):
Summarize
In the previous article, I explained how to create an Android.jar version of Original-android.jar. In this article, I demonstrated how to create a custom Android platform that uses the Original-android.jar. This is sufficient for using the hidden API, but there is a further step to using the internal API. This is because ADT still prohibits the use of classes in the Com.android.internals package (see above). In the next article, I'll show you how to customize ADT to allow the use of internal APIs.
Original: http://mogoweb.net/archives/104