Add prebuilt jar to system image - android 9.0

1,193 views
Skip to first unread message

KarenL

unread,
Mar 18, 2019, 3:35:58 PM3/18/19
to Android Building
Hi

I would like to add a couple of prebuilt jars and some source files to the Android 9 aosp image that I"m building.
With lower versions of Android I've added these easily to frameworks.jar. This was straight forward to do when framework.jar was built using a make file. Its a lot less clear how to do this using blueprint files and soong.

This is what I've tried and its not enough. 

Add a new folder to frameworks/base for my source files:
frameworks/base/myfolder/java/com/xxx

Edit the Android.bp file in frameworks/base and add source files to the "srcs" list
"myfolder/java/com/xxx/source1.java"
"myfolder/java/com/xxx/source2.java"

Edit the "static_libs" list and add my prebuilt jars
"prebuilt_jar1",
"prebuilt_jar2",

I'm not sure where to put these prebuilt jars. 
Do they go somewhere inside myfolder? Where are the other static libs in this list picked up from? 
Do I need to create .bp files inside myfolder to build this new part?

Do you have any suggestions as to how to add prebuilt jars to Android 9.

Thanks for your help.
Karen

Colin Cross

unread,
Mar 18, 2019, 4:06:45 PM3/18/19
to android-...@googlegroups.com
You need to use java_import modules to create a module for the jars.  Something like:

java_import {
    name: "my_prebuilt_jars",
    jars: [
        "my_prebuilt_jar1.jar",
        "my_prebuilt_jar2.jar",
    ],
}

Then you can add to static_libs:
        "my_prebuilt_jars"

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

KarenL

unread,
Mar 18, 2019, 4:34:25 PM3/18/19
to Android Building
What directory should my prebuilt jars go into? Where are the pother static_libs, like android.hardware.radio-V1.0-java, picked up from?
Where do I add this new Android.bp with the below content?

All I want to add to framework.jar are 2 prebuilt jars and 2 source files. Do I need to create a new folder structure under frameworks/base for these? If so - what does that structure look like.

Thank you for your help.

Colin Cross

unread,
Mar 18, 2019, 5:33:13 PM3/18/19
to android-...@googlegroups.com
All of that is up to you.  All Android.bp files found in the tree are parsed, so you can create a directory anywhere (maybe under vendor/ so you can minimize changes to AOSP files).  Put the prebuilt jars in that directory too.

static_libs takes a list of module names.  android.hardware.radio-V1.0-java is a module created by hardware/interfaces/radio/1.0/Android.bp.  The modules can be defined anywhere in the tree.

Taking a step back, what are you trying to accomplish?  Why do you need extra classes in framework.jar?  Maybe it would be better to keep them outside framework.jar but add them to the default classpath using PRODUCT_BOOT_JARS?  Or ship them as a separate shared library that apps can opt into loading?

KarenL

unread,
Mar 18, 2019, 5:52:12 PM3/18/19
to Android Building
I actually have everything in vendor and I'd prefer to keep it there. I'm not sure how to include whats in vendor in framework.jar.
This is the structure of the stuff I have in vendor that I would like to include.
vendor/xxx/lib -> the prebuilt jars are here
vendor/xxx/src/com/aaa/bbb/ccc => the source files are here

Question: Should I add an Android.bp to vendor/xxx/
It sounds like that should contain the java_import section you already mentioned.
How do I include the source files in the new Android.bp?

Question: How do I reference this not module from Android.bk in frameworks/base/Android.bp?

Is there any documentation on how to set up Android.bp files. I've been looking around and I cant find anything.

I need the extra classes because I'm adding a new system service to the build that I'm making.

Thank you again for your help.

Colin Cross

unread,
Mar 18, 2019, 6:36:17 PM3/18/19
to android-...@googlegroups.com
The basics on Android.bp files are documented at https://android.googlesource.com/platform/build/soong/+/master/README.md, and the documentation on the module types and their properties is at https://ci.android.com/builds/latest/branches/aosp-build-tools/targets/linux/view/soong_build.html.

Vinayak Soni

unread,
May 7, 2019, 3:42:40 PM5/7/19
to Android Building
Hi Colin,

How to write an Android.bp for a prebuilt jar that needs to be added to PRODUCT_BOOT_JARS?

Thanks,
Vinayak

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.

Colin Cross

unread,
May 7, 2019, 4:22:15 PM5/7/19
to android-...@googlegroups.com
What is in the jar, class files or dex files?

Vinayak Soni

unread,
May 13, 2019, 9:36:46 PM5/13/19
to Android Building
Classes.

Colin Cross

unread,
May 14, 2019, 12:45:11 PM5/14/19
to android-...@googlegroups.com
You can probably use something like:

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

java_library {
    name: "mylibrary",
    static_libs: ["mylibrary-jar"],
    installable: true,
}

Reply all
Reply to author
Forward
0 new messages