What is the correct way of developing an Android platform application using Android Studio (or other IDE)

Viewed 354

I am currently working on an Android AOSP project for which I am developing a java module which will be a part of the core services (such as the Phone app, for example).

There are some frameworks I use which are not exposed by default to "regular" apps (which lay in the private framework.jar).

For example: There are places I directly use android.app.IActivityManager's Binder API.

I do own the platform keys, but I not prefer compiling the whole AOSP framework each time I want to make a change.

I also prefer working with Android Studio, but will compromise on compiling the application through the terminal, if not possible.

What is the correct way of working on a project of this kind?

How do AOSP's developers develop their code without re-compiling the whole framework each time?

Update:

The best way I've found so far is to simply create an android studio project, get the framework.jar from the device (adb pull /system/framework/framework.jar) or from the AOSP source code, and add it as a compileOnly or runtimeOnly dependency in the gradle.build file of your app.

dependencies {
    compileOnly files('libs/framework.jar')
    implementation 'com.android.support:recyclerview-v7:28.0.0'
}

Then just add android:sharedUserId="android.uid.system" to the Android Manifest and compile it using the platform keys.

It should be installable as is.

This post seems to sum it up pretty good: https://kwagjj.wordpress.com/2017/10/27/building-custom-android-sdk-from-aosp-and-adding-it-to-android-studio/comment-page-1/

Is there any other way?

1 Answers

You can wrap those API callings to a new manager and service. For example, you have a manager called CustomManager, and it will call IActivityManager or other private/hidden API directly. And then you can create a module for you CustomManager, and build jar/aar for it. After every changing, you can copy that generated jar/aar file to you AndroidStudio project. You can use it as a normal library. Actually, there are some examples in AOSP source code, such as SystemUISharedLib, wrapper of SystemUI internal API, used by Launcher3.

Related