Git Product home page Git Product logo

aosp-android-jar's Introduction

aosp-android-jar

jar包使用方法:

替换 ${Android Sdk}/platforms/andorid-api/ 下的android.jar,之后sync一下。

针对非 SDK 接口的限制说明

有以下情况需要说明一下:

  • 能调用到不代表可以调用,例如黑名单api还是会受到上面限制

  • 如果你是系统应用,或者有root权限可以无视以上限制

  • Android.jar的接口和当前AOSP接口保持一致,但是部分类会做修改,修改是添加旧系统接口,修改会添加在对应Jar包目录说明中,需要简短适配,例如:

 final IPackageInstaller iPackageInstaller = AppGlobals.getPackageManager().getPackageInstaller();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
                packageInstaller = new PackageInstaller(iPackageInstaller, null, null, UserHandle.myUserId());
            } else {
                packageInstaller = new PackageInstaller(iPackageInstaller, null, UserHandle.myUserId());
            }
  • 部分新版sdk接口的返回值可能和旧版sdk接口不同,那么如果不接收返回值,则可能导致编译正常运行报错,这种情况需要判断使用反射形式调用,例如:
//此方法在api29和28之前返回值不同
lockPatternUtils.saveLockPassword(it, null, DevicePolicyManager.PASSWORD_QUALITY_COMPLEX, UserHandle.myUserId())

使用这种方式有什么好处:

  • 有调用提示,方法列表可以点出来

  • 减少适配成本,版本更新之后,不适配的方法会直接以错误的形式体现出来,不会如反射一样直接编译通过而运行时报错

  • 无意中会学会更多知识,列出方法列表会更加接近源码,偶尔留下的印象也许会在某天突然融会贯通

License

MIT License

Copyright (c) 2020 鼎鼎鼎

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


aosp-android-jar's People

Contributors

reginer 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

aosp-android-jar's Issues

授人以渔

大佬你好,我自己拉取了aosp的源码编译后,将framework.jar拿出来是不能用的,请问您用了什么方法编译生成此文件的呢?

Process to create android.jar

Hi ,

Could you provide some documentation for how the android.jar is created.
I have synced the AOSP source code for API 34 (android-14.0.0_r50)

Thanks

api 28以前的jar包

您好,请问有关于api 28以前的jar包吗?因为项目中使用到的api为26.

请教一下service.jar这个文件是做什么的?怎么用?

能遇到这么项目真是太幸运了,我可以不用下载源码再去编译,只用替换一下jar包就能查看很多源码,android.jar简直就是一个活宝,和他同一目录的service.jar我想肯定也不会差到哪去,所以想请教一下service.jar这个文件我该怎么使用他.万分感谢~~~

有的源码找不到

阅读源码的时候发现有的源文件找不到,
比如 ActivityManagerService

缺少 sun.**

比如
sun.misc.Unsafe.**
public native long java.lang.reflect.Field.getArtField()
这些可以加上吗?

Request

please add systemui and settings jar android 13

Difference between source folder and android.jar

I'm trying to build an app using the EthernetManager. This class is hidden so I found this project.

The source file at https://github.com/Reginer/aosp-android-jar/blob/main/android-32/src/android/net/EthernetManager.java looks as expected but when i use the https://github.com/Reginer/aosp-android-jar/blob/main/android-32/android.jar file in my SDK, the EthernetManager class has completely different methods exposed.

I'm I using the wrong files here?

Are you really compiling it from source?

Really?
A lot of classes missed.
What the point of copying sources and building android.jar?

Just build AOSP, get frameworks.jar && android.jar and merge it together!

Do not use this repository, it lacks a log of APIs and maybe some classes are damaged.

Use of services.jar

Is it possible to gain access to a local system server using the com.android.server.* classes directly without root? In this case I'm attempting to invoke a system service object via it's abstract class such as this:

import com.android.server.LocalServices;
import com.android.server.lights.LightsManager;

lm = LocalServices.getService(LightsManager.class);

I've used the older version of the android API 30 jar at https://github.com/anggrayudi/android-hidden-api which includes both framework and services and compiled with an older version of Android Studio successfully. When running the code however, the classes are not found when running. Would reflection (such as with the LSPosed library) allow for this section of the API to be accessed, or is it off limits due to permissions altogether?

替换32的android.jar在AS编译报错 , This feature requires ASM7

太感谢作者你这个android.jar包,我采用你的android.jar替换在28、30上都很正常,但是使用32的时候,AS编译的时候就报如下错误

* What went wrong:
Execution failed for task ':testA:parseDebugLocalResources'.
> Could not resolve all files for configuration ':testA:androidApis'.
   > Failed to transform android.jar to match attributes {artifactType=android-platform-attr, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for PlatformAttrTransform: C:\Users\jun\AppData\Local\Android\Sdk\platforms\android-32\android.jar.
         > This feature requires ASM7

希望作者能百忙之中帮忙解答下该如何处理 ,万分感谢❤

Could not resolve all files for configuration ':app:androidApis'. Unsupported class file major version 61

Hello, I followed the android.jar file replacement guide. However, when I change the Build Variants or build.gradle and have to re-sync the project afterwards, I get the error:

Could not resolve all files for configuration ':app:androidApis'.
Failed to transform android.jar to match attributes {artifactType=android-mockable-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime, returnDefaultValues=false}.
Execution failed for MockableJarTransform: C:\ProgramData\Sdk\platforms\android-34\android.jar.
Unsupported class file major version 61

After that, I tried updating java from JDK-11 to JDK-17 and tried to clean it up then rebuild the project, at this point, only the error Unsupported class file major version 61 appeared.

I tried Invalidate Caches/Restart but still didn't fix the above error.

My Android Studio Info:

  • Android Studio Arctic Fox (2020.3.1 Patch 4)
  • Android Gradle Plugin Version: 7.0.4
  • Gradle Version: 7.0.2

引入serivces.jar报错

项目中进入api-31的services.jar放到libs下,build.gradle中加入compileOnly files('libs/service-api-31.jar'),编译时报错
com.android.tools.r8.internal.Jc: Absent Code attribute in method that is not native or abstract
请帮忙看看是哪里的问题

关于维护和更新

每个版本的android.jar会在AOSP更新第一个正式版之后进行新版本添加。

因为源码大小的关系,只会保存当时编译jar包时采用的AOSP版本源码。

android-33举例,Android13-r3版本是Android13正式发布的第一个版本源码,那么这个分支就是编译版本,同时android-32不再更新。

引用api34报错的情况

感谢大神编译34的api,我把这个jar替换到api目录里同步后发现一些报错如下
错误的类文件: D:\sdk\platforms\android-34\android.jar(/android/os/Parcel.class)
类文件具有错误的版本 61.0, 应为 55.0
请删除该文件或确保该文件位于正确的类路径子目录中。
D:\SoulTweaks\app\src\main\java\android\dolby\DsClientSettings.java:4: 错误: 无法访问Parcelable
import android.os.Parcelable;
^
错误的类文件: D:\sdk\platforms\android-34\android.jar(/android/os/Parcelable.class)
类文件具有错误的版本 61.0, 应为 55.0
请删除该文件或确保该文件位于正确的类路径子目录中。

类似的还有很多

Hello,我自行添加了一些文件到 Android.jar里面之后报了这个错误请问下有没有遇到过呢?Could not resolve all files for configuration ':app:androidApis'.

Could not resolve all files for configuration ':app:androidApis'.
Failed to transform android.jar to match attributes {artifactType=android-mockable-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime, returnDefaultValues=false}.
> Execution failed for MockableJarTransform: /Users/tomorrow/Library/Android/sdk/platforms/android-32/android.jar.
> Cannot read field "outgoingEdges" because "handlerRangeBlock" is null

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.