How to include prebuilt jars using bp in Android P

4,393 views
Skip to first unread message

Ajay kumar

unread,
Nov 20, 2018, 10:32:21 AM11/20/18
to Android Building
Hi 
Added jar file :

this my Android.bp

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


am getting build error :
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.


Thanks
Ajay

Jovanovic, Zoran

unread,
Nov 22, 2018, 9:07:20 AM11/22/18
to Android Building
Hi.


The library doesn't need to be referenced in PRODUCT_PACKAGES, as it seems that it's not what it is. Your jar does however need to be accessible to Soong, e.g. in the 'prebuilts' project that Soong queries for all libraries (less likely) or in a path relative to your app's Android.bp (more likely). For example, copy the jar to your app's 'lib' folder and change


java_import {

name: "my-services",

- jars: ["my-services.jar"],

+ jars: ["lib/my-services.jar"],

}


Next, in your build target, e.g. android_app, refer to the library by its java_import/name ("my-services" in your case) in one of the libraries blocks (depending on how you want it linked). That should be about it. Good luck.


Cheers

Zoran Jovanovic

SW Architect

Sony Mobile Communications Inc.

Lund, Sweden


________________________________
From: android-...@googlegroups.com <android-...@googlegroups.com> on behalf of Ajay kumar <ajayre...@gmail.com>
Sent: Tuesday, November 20, 2018 13:49
To: Android Building
Subject: [android-building] How to include prebuilt jars using bp in Android P

Hi
Added jar file :

this my Android.bp

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


am getting build error :
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<http://base.mk/> under build/make/target/product/ and device/google/mydevice.mk<http://mydevice.mk/> to PRODUCT_PACKAGES.


Thanks
Ajay


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

Ajay kumar

unread,
Nov 28, 2018, 10:06:08 AM11/28/18
to Android Building
Hi Zoran,
Thanks for your reply.
Our intention is to include this jar in system/frameworks as like frameworks.jar(which has been built on an engineering environment), it has to be used by a system service in frameworks. can you tell me how this can be achievable ??

Thanks,
Ajay

Jovanovic, Zoran

unread,
Dec 5, 2018, 12:26:29 PM12/5/18
to Android Building
Ah, sorry for misunderstanding.


Put "installable: true" somewhere under "java_library" in your library's blueprint.


Cheers

--

Zoran Jovanovic
SW Architect
Sony Mobile Communications Inc.
Lund, Sweden


________________________________
From: android-...@googlegroups.com <android-...@googlegroups.com> on behalf of Ajay kumar <ajayre...@gmail.com>
Sent: Wednesday, November 28, 2018 08:51
To: Android Building
Subject: [android-building] Re: How to include prebuilt jars using bp in Android P

Hi Zoran,
Thanks for your reply.
Our intention is to include this jar in system/frameworks as like frameworks.jar(which has been built on an engineering environment), it has to be used by a system service in frameworks. can you tell me how this can be achievable ??

Thanks,
Ajay

On Tuesday, November 20, 2018 at 9:02:21 PM UTC+5:30, Ajay kumar wrote:
Hi
Added jar file :

this my Android.bp

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


am getting build error :
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

Ronny Pau

unread,
Jan 18, 2019, 12:02:48 PM1/18/19
to Android Building
I have the same problem too.

I have a prebuilt jar that needs to be brought in, I have tried both java_import and java_library directives and neither works. Ideas?

>>> java_import - seems to only create immediates but doesn't actually bring the the jar to my target directory 
java_import {
      name: "myPrebuiltJar",
      jars: ["myPrebuiltJar.jar"],
  }

>>> java_library - I see some immediates and the jar in my target directory, but callers that makes use of the library do not recognize / cannot import my package (build time error)
java_library {
    name: "myPrebuiltJar",
    srcs: ["myPrebuiltJar.jar"],
    installable: true,
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com<mailto:android-building+unsubscribe@googlegroups.com>.

Colin Cross

unread,
Jan 18, 2019, 2:11:06 PM1/18/19
to android-...@googlegroups.com
I'd suggest combining the two:

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

java_library {
    name: "myPrebuiltJar",
    static_libs: ["myPrebuiltJar-prebuilt"],
    installable: true,
}


To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com<mailto:android-buildi...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

--
--
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.

Ronny Pau

unread,
Jan 21, 2019, 11:42:33 PM1/21/19
to android-...@googlegroups.com
That's one thing I have tried, but I am running into the following problem around "Duplicate path classes.dex found", it seems like the classes.dex from within the JAR is clashing with the one being produced by java_library.

Then I tried to add the "dex_preopt" directive and setting enabled to false, everything builds but the caller still doesn't see the package.








You received this message because you are subscribed to a topic in the Google Groups "Android Building" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/android-building/XosHgl6YFaM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to android-buildi...@googlegroups.com.

Colin Cross

unread,
Jan 22, 2019, 12:16:31 AM1/22/19
to android-...@googlegroups.com
There is no way to import a jar containing classes.dex files, you need to import a jar containing .class files.
Reply all
Reply to author
Forward
0 new messages