Coder Social home page Coder Social logo

anggrayudi / android-hidden-api Goto Github PK

View Code? Open in Web Editor NEW
3.4K 133.0 642.0 327.11 MB

A library that provides access to Android hidden APIs and internal resources.

License: Apache License 2.0

Java 98.94% Kotlin 1.06%
android android-framework internal-resources java api

android-hidden-api's Introduction

Android Hidden APIs

Android Hidden APIs are classes, methods and resources that Google hides from you because of stability reason. These features are hidden because they may be changed on next API version.

The internal APIs are located in package com.android.internal and available in the framework.jar, while the hidden APIs are located in the android.jar file with @hide javadoc attribute. Now you know the difference. But I will refer to both as hidden APIs.

This repo contains custom android.jar which you can use to develop your app. However, if you urgently need to create your own android.jar, I also share you the Krabby Patty secret recipe here: Create Your Own Android Hidden APIs.

Use Custom android.jar

  1. Download custom android.jar from Google Drive.
  2. Go to <SDK location>/platforms/.
  3. Copy, paste and replace the downloaded hidden API file into this directory, e.g. android-30/android.jar.
  4. Change compileSdkVersion and targetSdkVersion to 30 (for example).
  5. Finally, rebuild your project.

Note: Higher compileSdkVersion and targetSdkVersion will be better.

Resources Helper

Maven Central

If you plan to use only Android internal resources rather than internal classes or methods, do:

dependencies {
    implementation 'com.anggrayudi:android-hidden-api:30.0'
}

Here's some example of accessing internal resources:

String accept = InternalAccessor.getString("accept");
float sbar_height = InternalAccessor.getDimension("status_bar_height");
int notif_color = InternalAccessor.getColor("config_defaultNotificationColor");

Contributing

If you have your own custom android.jar and want to add it to Google Drive, please create an issue. I will upload it.

License

Copyright 2015-2020 Anggrayudi Hardiannicko A.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

android-hidden-api's People

Contributors

anggrayudi avatar johnjohndoe avatar trumeet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-hidden-api's Issues

android26.jar compile err

Could not resolve all files for configuration ':app:androidApis'.
Failed to transform file 'android.jar' to match attributes {artifactType=android-mockable-jar, returnDefaultValues=false} using transform MockableJarTransform

studio show this error message when i replace the android.jar of android-26

compile failed if use Databinding in project

I used android-hidden-api in my project, but After enable DataBinding, add following code:

dataBinding { enabled true }

            android:onClick="@{mainActivity::clickHelloWorld}"

compiled failed about: Error: com.test.test.databinding not exist. Compile success if I don't use android.jar in android-hidden-api project. any help is welcome!

ps: English is not my mother tongue; please excuse any errors on my part.

About API 25...

I get this:

D:\Desktop\android-hidden-api\sample\android-hidden-api\src\main\java\com\anggrayudi\hiddenapi\InternalAccessor.java
Error:(43, 73) error: package com.android.internal.R does not exist
Error:(44, 73) error: package com.android.internal.R does not exist
Error:(45, 73) error: package com.android.internal.R does not exist
Error:(46, 73) error: package com.android.internal.R does not exist
Error:(47, 73) error: package com.android.internal.R does not exist
Error:(48, 73) error: package com.android.internal.R does not exist
Error:(49, 73) error: package com.android.internal.R does not exist
Error:(50, 73) error: package com.android.internal.R does not exist
Error:(51, 73) error: package com.android.internal.R does not exist
Error:(52, 73) error: package com.android.internal.R does not exist
Error:(53, 73) error: package com.android.internal.R does not exist
Error:(54, 73) error: package com.android.internal.R does not exist
Error:(55, 73) error: package com.android.internal.R does not exist
Error:(56, 73) error: package com.android.internal.R does not exist
Error:(57, 73) error: package com.android.internal.R does not exist
Error:(58, 73) error: package com.android.internal.R does not exist
Error:Execution failed for task ':android-hidden-api:compileReleaseJavaWithJavac'.

Compilation failed; see the compiler error output for details.

SDK 22 not working?

I tried this with SDK 22 but when I switch to the one downloaded here the basic objects are missing. For example Object and String are not found. I did some research and apparently the process for Lollipop is changed as follows:

For Lollipop the flow is little different:

    Get /system/framework/arm/boot.oat from lollipop device
    Use 'java -jar oat2dex.jar boot boot.oat'
    You will got 2 folders: dex and odex. Go to dex and make 'java -jar dex2jar.jar framework.dex'
    Rename resulting framework.jar to .zip, extract and find classes you need
    Go to [sdk_path]/platforms/[target_platform] and extract android.jar (first rename it to zip).
    Copy files from extracted framework to extracted android.jar. Then compress to zip and rename to .jar :)

Cannot access some resources

I cannot access some resources. For example: @android:attr/theme is accessable, but @android:attr/pointerStyle isn't. However, when you look with APK Tool, the identifier exists in resources.arsc. I would like to see this resources unhidden.

Will this api work if

Hi,
Sorry for creating issue as i didn't find any way to reach you. Will this api work if the app (debug variant) is deployed on real device? Because i'm afraid it will not.

I think this is only good if you want to test app on emulator. Please have your kind words on this comment before you delete this.

Thanks

android-23, Constant expression required

这个变量会报错 MeasureSpec.UNSPECIFIED

switch (MeasureSpec.getMode(measureSpec)) {
            case MeasureSpec.UNSPECIFIED:
                result = desired;
                break;
            case MeasureSpec.AT_MOST:
                result = Math.max(specSize, desired);
                break;
            case MeasureSpec.EXACTLY:
            default:
                result = specSize;
        }

default method found in version 50.0 classfile

Error:(19, 20) error: cannot access Editable
bad class file: D:\ANDROID\DEVELOPMENT\ADT\sdk\platforms\android-24\android.jar(android/text/Editable.class)
default method found in version 50.0 classfile
Please remove or make sure it appears in the correct subdirectory of the classpath.

Having build error

When importing and trying to build the sample project, I get this error:

Information:Gradle tasks [:app:assembleDebug]
C:\Users\User\Desktop\android-hidden-api\sample\android-hidden-api\src\main\java\com\anggrayudi\hiddenapi\InternalAccessor.java
Error:(43, 73) error: package com.android.internal.R does not exist
Error:(44, 73) error: package com.android.internal.R does not exist
Error:(45, 73) error: package com.android.internal.R does not exist
Error:(46, 73) error: package com.android.internal.R does not exist
Error:(47, 73) error: package com.android.internal.R does not exist
Error:(48, 73) error: package com.android.internal.R does not exist
Error:(49, 73) error: package com.android.internal.R does not exist
Error:(50, 73) error: package com.android.internal.R does not exist
Error:(51, 73) error: package com.android.internal.R does not exist
Error:(52, 73) error: package com.android.internal.R does not exist
Error:(53, 73) error: package com.android.internal.R does not exist
Error:(54, 73) error: package com.android.internal.R does not exist
Error:(55, 73) error: package com.android.internal.R does not exist
Error:(56, 73) error: package com.android.internal.R does not exist
Error:(57, 73) error: package com.android.internal.R does not exist
Error:(58, 73) error: package com.android.internal.R does not exist
Error:org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details.

THis does not have all hidden APIs

Basically android.jar is not only framework.jar, but also contains classes from a few other common libraries

We at AOKP need internal APIs to build some of our apps, so we have a script to generate android.jar with all methods.

As you can see in the script here
https://github.com/AOKP/build/blob/mm/tools/customsdkgen.sh#L16
all these classes need to be present in the android.jar
basically this is spread out across

  • framework.jar
  • framework2.jar
  • core.jar
  • telephony.jar

clean Error:Execution failed for task ':app:mockableAndroidJar'. > java.lang.NullPointerException (no error message) in Android Studio 2.2

Error:

20161004103811

gradle:

···
compileSdkVersion 23
buildToolsVersion "23.0.3"
···

This error comes when using your lib of android-23, and it disappear when using the original android-23.jar.

We know task ':app:mockableAndroidJar' is experimental in Android Studio 2.1.3, and I close this.

Android Studio clean 时产生 Error:Execution failed for task ':app:mockableAndroidJar' > java.lang.NullPointerException (no error message)

but google makes this stable in Android Stuido 2.2, and I can't this.

This error comes for some days until today I found this may be result from your lib.

Android Studio 3.2.0 sync error: Failed to transform android.jar

As 3.2.0 sync error with api27 in this repo:

Could not resolve all files for configuration ':app:androidApis'.
Failed to transform file 'android.jar' to match attributes {artifactType=android-mockable-jar, returnDefaultValues=false} using transform MockableJarTransform

sample project not working

First of all the IDE complains it can't resolve AppCompatActivity. Strangely it still can compile and install the APK onto the test device.

However, when running the app, this list isn't found by findById the result is null. NullpointerExceptions follow.

Android-25, View$InvalidateInfo not found

I have put the android-25 android.jar in my platforms/android-25 folder, we have some projects that work but some of them get this error when building which I'm not sure how to proceed on.

error: cannot access InvalidateInfo
class file for android.view.View$InvalidateInfo not found
Consult the following stack trace for details.
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for android.view.View$InvalidateInfo not found

24 compile error

Error:(50, 20) error: cannot access Editable
bad class file: /home/jp/Android/Sdk/platforms/android-24/android.jar(android/text/Editable.class)
default method found in version 50.0 classfile
Please remove or make sure it appears in the correct subdirectory of the classpath.

Sample project with appcompat for android-22

So I think the issue with android-22 comes down to the fact that, if you have an sdk beyond 22 installed, the Android Studio project wizard is a bit dense when in creates the build.gradle file for the module. Specifically it uses the later api com.android.support libraries.

If you uninstall later sdk's then the wizard generates the correct build.gradle file for the module that works with the hidden-api. I would like to suggest that you document the build.gradle requirements for the module for each API. But maybe it should be obvious. In any case for android-22 I have attached a sample project that builds with the main issue being the build.gradle for the module that will work is this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.burningthumb.simpletest"
        minSdkVersion 22
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:design:22.2.1'
}

SimpleTest.zip

Can't work

When I use the android.jar (API 22) in your project, I get a error:

Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '\Android\sdk\build-tools\23.0.2\aapt.exe'' finished with non-zero exit value 1
I don't know why, what's more, the built-in type can't be recognized and need import, like String int and more. I don't know why.

My IDE is Android Studio, update to the latest.

How to merge android.jar and framework.jar?

This work looks really impressive!
I am using an Android phone with some extended API's, so the android.jar file exposes a few more classes and methods than normal.
The effect is that I cannot use the android.jar files published here, but will have to merge android.jar and framework.jar myself.
Could you please share information about how to do this?

Not compatible with Robolectric > 3.2

Tested on API level 25 and 26, if I'm using Robolectric 3.2, it's still working. But for some reason that version is not compatible with powermock. Then I upgrade to 3.3 it stops working by raising very weird error like below:

java.lang.StringIndexOutOfBoundsException: String index out of range: -3

	at java.lang.String.substring(String.java:1931)
	at org.robolectric.res.ResourceTableFactory.addMissingStyleableAttributes(ResourceTableFactory.java:88)
	at org.robolectric.res.ResourceTableFactory.newFrameworkResourceTable(ResourceTableFactory.java:17)
	at org.robolectric.RobolectricTestRunner.getCompiletimeSdkResourceTable(RobolectricTestRunner.java:243)
	at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:293)
	at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:222)
	at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:110)
	at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:37)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.robolectric.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:64)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

If I switch SDK back to the original one, it will work perfect. I test 3.3, 3.4 to 4.0 (latest) of robolectric and non of them works.

android-28.jar compile error: Cannot access hidden methods

permission error when access method.
eg:

SpannableString spannableString = new SpannableString("hello world");
spannableString.setSpan(new AbsoluteSizeSpan(12), 0, 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

it will tip error when build project.

android hidden api for android 28

I using your android hidden api for android 28 and found some bug.
it does not contain IPackageInstallObserver interface and PackageManager class doesnot contain installPackage method.
My application work well with android hidden api version 27
could you please check and fix it
Thanks

Cannot import hidden class

I've replaced the Android.jar for corresponding version. When I import a hidden class, it recognized as unknown class and automatically hide that import statement. And then I still cannot use the class in my Main activity.

android-23 will cause build error Constant expression required

I am using android-23 jar.

switch (MeasureSpec.getMode(measureSpec)) {
            case MeasureSpec.UNSPECIFIED:
                result = desired;
                break;
            case MeasureSpec.AT_MOST:
                result = Math.max(specSize, desired);
                break;
            case MeasureSpec.EXACTLY:
            default:
                result = specSize;
        }

MeasureSpec.UNSPECIFIED will cause a compile error: Constant expression required
because the switch statement require a constant expression.

This bug is not fixed. There is a same issue closed but not fixed.

#10

IWindowManager.Stub cannot be found in android-23.jar

Many Thanks!
As I use android-23.jar provided by your project, IWindowManager.Stub.asInterface class cannot be found.
But I have checked the android open source of google, IWindowManager.Stub exists as a hidden api.

Can't import classes from com.android.internal

Hello, I added your jar for 23 API, added dependecies and repository, tried to rebuild the project and get error:
Error:Execution failed for task ':app:mockableAndroidJar'.

java.lang.NullPointerException (no error message)
Also classes from com.android.internal AS can't see, can you help to fix this?

Building v22

Hey there!

First of all, many thanks for getting v22 up, it going to save me so much time once it compiles!

I've managed to get v21 running, but I need v22, so I grabbed it, and whacked it in /sdk/platform/android-22, but I cannot get it to compile. I looked at the previous issues raised here, and my problem is not that I'm using v23 build tools. This is my gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.0"

    defaultConfig {
        applicationId "REDACTED"
        minSdkVersion 22
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:22.0.+'
}

As you can see, AppCompat is 22, compileVersion is 22, buildTools is 22, everything is 22. The issue gradle is reporting:

Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Users/botondbutuza/Library/Android/sdk/build-tools/22.0.0/aapt'' finished with non-zero exit value 1

The first line of the exception thrown with --debug and --stacktrace is

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugResources'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)

Not sure if that helps, but there it is.

Any help would be greatly appreciated. Have you managed to build a project with v22?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.