How to include prebuilt jars using bp in Android P

3,127 views
Skip to first unread message

shankar kumar yellapu

unread,
Sep 24, 2018, 11:11:46 AM9/24/18
to Android Building
Hi,

I'm trying to include a jar in /frameworks/base/services/myservice using bp . My bp file looks like this:

java_library_static {
    name: "my-service",
    static_libs: ["my-services-prebuilt"],
}

I've copied my prebuilt jar in the same location with the name my-services-prebuilt. I'm getting the following error:

error: frameworks/base/services/my-services/Android.bp:29:1:"my-services" depends on undefined module ",my-services-prebuilt"

FYR: my make file in Android O

LOCAL_PATH:= $(call my-dir)

# static jar
# ============================================================
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := my-services-prebuilt:my-services-prebuilt.jar
include $(BUILD_MULTI_PREBUILT)

# shared jar
# ============================================================
include $(CLEAR_VARS)
LOCAL_MODULE := my-services
LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_JAVA_LIBRARIES := my-services-prebuilt
include $(BUILD_JAVA_LIBRARY)
endif



Can anybody tell me what I'm doing wrong?? Please send me proper bp script.

Regards,
Shankar

Dan Willemsen

unread,
Sep 24, 2018, 5:05:38 PM9/24/18
to Android Building
You'll need to define your prebuilt using java_import:

  java_import {
      name: "my-services",
      jars: ["my-services-prebuilt.jar"],
  }

You shouldn't need the my-services vs my-services-prebuilt differentiation like you did with make.

- 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.
For more options, visit https://groups.google.com/d/optout.

shankar kumar yellapu

unread,
Sep 25, 2018, 1:23:15 PM9/25/18
to Android Building
Hi Dan,
Thanks for quick reply, But my actual import from frameworks/base/services/core/java/com/example/sevice/myservice.java is saying error: package com.my.service.addon does not exist.

If I give mm in frameworks/base/services/myservices/ says build successful.

My Android.bp under /frameworks/base/services/ is as following:

// merge all required services into one jar
// ============================================================
java_library {
    name: "services",

    dex_preopt: {
        app_image: true,
        profile: "art-profile",
    },

    srcs: [
        "java/**/*.java",
    ],

    // The convention is to name each service module 'services.$(module_name)'
    static_libs: [
        "services.core",
        "services.accessibility",
        "services.appwidget",
        "services.autofill",
        "services.backup",
        "services.companion",
        "services.coverage",
        "services.devicepolicy",
        "services.midi",
        "services.net",
        "services.print",
        "services.restrictions",
        "services.usage",
        "services.usb",
        "services.voiceinteraction",
        "android.hidl.base-V1.0-java",
    ],

    libs: [
        "android.hidl.manager-V1.0-java",
        "my-services",
    ],

    // Uncomment to enable output of certain warnings (deprecated, unchecked)
    //javacflags: ["-Xlint"],

}

// native library
// =============================================================

cc_library_shared {
    name: "libandroid_servers",
    defaults: ["libservices.core-libs"],
    whole_static_libs: ["libservices.core"],
}


am I missing anything here???

Thanks,
Shankar

Dan Willemsen

unread,
Sep 25, 2018, 7:07:14 PM9/25/18
to Android Building
To compile that frameworks/base/services/core/java/com/example/sevice/myservice.java file, you'd need to add your lib to the libs section of services.core.unboosted in frameworks/base/services/core/Android.bp.

- Dan

shankar kumar yellapu

unread,
Sep 26, 2018, 3:01:09 AM9/26/18
to Android Building
Thanks Dan, I did the same It's working fine. Thank you very much.

-Shankar

shankar kumar yellapu

unread,
Sep 26, 2018, 9:51:25 AM9/26/18
to Android Building
Hi Dan,

I've given a fresh build, now I'm getting new error as follows:

ninja: error: 'out/target/common/obj/JAVA_LIBRARIES/my-services_intermediates/javalib.jar', needed by 'out/target/product/mydevice/dex_bootjars/system/framework/arm64/boot.art', missing and no known rule to make it

I've added my-services in base.mk under build/make/target/product/ and device/google/mydevice.mk to PRODUCT_PACKAGES.

Is there anything I'm missing??

-Shankar

Ronny Pau

unread,
Jan 18, 2019, 2:52:50 PM1/18/19
to Android Building
I am going through the exact same thing, I can't get the caller to pick up the package from my library.  Any updates?
Reply all
Reply to author
Forward
0 new messages