Preparation
You need to prepare these two files: classes-header.jar and android.jar.
android.jar
Go to /platforms/android-X, where X is the API version. If you want to create custom android.jar for API 29, then go to /platforms/android-29. Copy android.jar from this folder into a temporary folder where we will create our custom android.jar.
Don’t forget to keep the original android.jar because when we accidentally put something wrong, we can go back to the original version. Anyway, you can download the original one from:
https://dl.google.com/android/repository/platform-X_rY.zip
Where X is the API level and Y is the revision number. For example: https://dl.google.com/android/repository/platform-29_r04.zip
Extract the ZIP and you will find the original android.jar.
classes-header.jar
classes-header.jar located in /your_path/aosp/out/target/common/obj/JAVA_LIBRARIES/framework_intermediates
scp user@xxx.xxx.xxx.xxx:/home/user/RK3568_ROCKCHIP_ANDROID12.0_SDK/out/target/common/obj/JAVA_LIBRARIES\
/framework_intermediates/classes-header.jar .
Create Custom android.jar
Move all files from inside folder android into folder custom. Then open folder classes and move everything inside it into folder custom as well. Repeat the steps for the rest classes folders. Whenever you are asked to replace or merge, please select merge.
On Windows you may select Copy and replace.
Open your terminal and set the directory to folder custom. We will do the final step, creating the JAR.
Run the following command:
jar cvf android.jar *
Now we have our own custom android.jar:
Copy this android.jar into /platforms/android-29.
参考
https://hardiannicko.medium.com/create-your-own-android-hidden-apis-fa3cca02d345
使用原始文档中的 framework.jar 会导致AndroidStudio编译报错,替换为 classes-header.jar