How to create custom framework APIs

aosp

On this post, we will learn how to modify or create framework APIs on AOSP (Android Open Source Project).

Before start, let’s set a build environment and download AOSP source codes. Please follow steps on these links (environment and source code).

  • Make sure that you have at least 200GB of a free space.

 

Path to Work on

…/framework/base contains all framework libraries and APIs that we used to develop an app, e.g., android.app.Activity. So, all of our work will be done under this path either to modify existing framework APIs or to create new framework APIs.

(Will be updated) Framework APIs

(Will be updated) JNI (libraries)

 

Files Generated

After done with modifications, please follow these steps to build. Then, you will see these three  files generated.

Under <aosp-root>/out/target/product/<product-name>/system/framework/,

  • framework.jar: APIs accessible to applications
  • services.jar: Implementation of managers and system services located under frameworks/base/services.

Under <aosp-root>/out/target/product/<product-name>/system/lib/,

  • libandroid*.so: Libraries generated from native code (C/C++) like the .cpp files located at frameworks/base/core/jni.

 

Using Modified Framework APIs

After modification, we want to use the new framework APIs while building an app. However, current version of framework APIs that our machine uses is not updated yet. That means  our IDE cannot find the APIs. So, please replace files under ~/Library/Android/sdk/platforms/android-{version #}/This path can be different on your machine.

 

Leave A Comment

Your email address will not be published. Required fields are marked *