Modify the Android.jar itself to include the hidden API

Source: Internet
Author: User

In development often encounter the use of the Android hidden API, the usual practice is to call through reflection, but the reflection of the performance of the impact, the code is not intuitive, I prefer to directly use those APIs.

So this is the beginning of this article, self-transformation of a android.jar, so that it contains the hidden API


In fact, the steps are very simple, because the Framework.jar in the Android system already contains the hidden API, just extract it and put it inside the Android.jar, just sort it out:


1) Get Framework.jar from the specified version of ROM

2) Unzip the Android.jar in Framework.jar and Android SDK

3) Framework.jar The solution out of the things android.jar out of the things, to cover

4) RePack

5) Replace the original with the new Android.jar


For convenience, write a script to complete the above work, where the solution Framework.jar use the Dex2jar tool, please download and configure the environment variables yourself


#!/bin/sh

Dex=$1

Ajar=$2

Out=$3

d2j-dex2jar.sh $DEX-O Framework-dex.jar

MV Framework-dex.jar Framework-dex.zip

unzip-d Framework-dex Framework-dex.zip

CP $AJAR Android-sdk.zip

unzip-d ANDROID-SDK Android-sdk.zip

Cp-r-F framework-dex/* android-sdk/

CD ANDROID-SDK

Zip-r Android-new.zip *

Cd..

MV Android-sdk/android-new.zip Android-new.zip

MV Android-new.zip Android-new.jar

RM Android-sdk.zip

RM Framework-dex.zip

RM-FR android-sdk/

RM-FR framework-dex/

MV Android-new.jar $OUT

echo "Done"


It's also easy to use, save the script as a makesdk.sh and give the executable permission, then use the

$ makesdk.sh Framework.jar Android.jar ~/desktop/

After execution, you can see a file named Android-new.jar on your desktop, which is the SDK that contains the hidden API.


Modify the Android.jar itself to include the hidden API

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.