Android.bp can't link java static library built from Android,mk

1,701 views
Skip to first unread message

Jack Rong

unread,
Sep 18, 2019, 1:51:52 PM9/18/19
to Android Building
I have a scenario that is to link in a Java static library built from an Android.mk file to complete the whole AOSP image build in Android P. The build system somehow is not versatile enough to discover the static library built from other project using the Android.mk. Here is an example:

 1) Android.mk file at the "package/app/MyLibs"

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := libmine

LOCAL_SRC_FILES := \
$(call all-java-files-under, src/main/java) \
$(call all-Iaidl-files-under, src/main/aidl)

ifneq ($(filter 28,$(PLATFORM_SDK_VERSION)),)
LOCAL_PRIVATE_PLATFORM_APIS := true
else
LOCAL_SDK_VERSION := current
endif

LOCAL_STATIC_JAVA_LIBRARIES := libgson

LOCAL_PROGUARD_FLAG_FILES := proguard.flags

include $(BUILD_STATIC_JAVA_LIBRARY)


2) Android.bp at "frameworks/base/services/devicepolicy"

java_library_static {
    name: "services.devicepolicy",
    srcs: ["java/**/*.java"],

    libs: [
        "conscrypt",
        "services.core",
    ],
    static_libs: [
        "libmine",
    ],
}

3) Build message:

error: frameworks/base/services/devicepolicy/Android.bp:1:1: "services.devicepolicy" depends on undefined module "libmine"


Dan Willemsen

unread,
Sep 20, 2019, 3:42:30 PM9/20/19
to Android Building
All dependencies of an Android.bp file must be in Android.bp, not Android.mk. So you'll need to convert your libmine description to an Android.bp file.

- Dan

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/7b078f33-17a4-47c4-b202-7a29d08f0253%40googlegroups.com.

Jack Rong

unread,
Sep 20, 2019, 4:16:53 PM9/20/19
to Android Building
Thanks a lot Dan for your reply.  Here is my question to Google, why you break the backward compatibility like that. Would it be much better to let the "Android.bp" recognize the library or entity exported from Android.mk. There are hundreds of Android,mk files still exist in AOSP source tree in Android 10.

For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages