Home » Android » Android Build System » Convert Android.mk to Android.bp

Convert Android.mk to Android.bp

The source code which was developed prior to when Soong was introduced in Android build system, was compiled using Android.mk make files.

We have seen how to write a simple Android.mk and compile the source code using it in our post “Compile Android application as part of AOSP source code

In this post, we will convert the same Android.mk to Android.bp to avoid rewriting Soong based Android.bp build files.

Lets say, our source code we compiled using Android.mk is at Android_AOSP/packages/apps/HelloWorld , so we will first need to make sure “androidmk” tool is available in the compilation path,

$ cd Android_AOSP
$ source build/envsetup.sh
$ make blueprint_tools

Now, you will see the androidmk tool is available in path which you can verify as,

$ which androidmk

out/soong/host/linux-x86/bin/androidmk

Now, we need to change to directory where our source code and Android.mk is available,

$ cd packages/apps/HelloWorld

If we check the Android.mk we have written in the another post, we mentioned above is,

$ cat Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := HelloWorld
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
LOCAL_PROGUARD_ENABLED := disabled
include $(BUILD_PACKAGE)

Now convert the Android.mk to Android.bp as,

$ androidmk Android.mk

This will output the conversion on terminal as,

android_app {
    name: "HelloWorld",
    static_libs: ["android-support-v4"],

    srcs: ["src/**/*.java"],
    certificate: "platform",
    privileged: true,
    optimize: {
        enabled: false,
    },
}

You can save this converted file to Android.bp as,

$ androidmk Android.mk > Android.bp

Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment