Need help exposing library / class paths in AOSP P (Android 9) from my own .jar file inside vendor

2,666 views
Skip to first unread message

Elliott Mazzuca

unread,
Apr 15, 2019, 11:06:43 AM4/15/19
to Android Building
I tried to give a specific title and i will elaborate a bit more:

What i am trying to do is expose the classes that are inside my jar file so they are on the default class path.

I have a sample app to test if this is working that i created that would uses these classes.  But they don't appear in the images class path.  so i get a "ClassNotFound Exception" when i try to instantiate




I have a custom .Jar file where i have my own package, lets call it com.sample.myCustomLibrary

This jar file is created in the vendor space in AOSP P (android 9) using an Android.bp file.


inside my Android.bp file, i have a "java_library"

that looks like this:

// myCustomLibrary.jar
java_library
{
    name
: "com.sample.myCustomLibrary",
    owner
: "sampleOwner",
    installable
: true,




    javacflags
= [
       
"-Xmaxwarns 9999999",
   
],


    srcs
: [
       
"lib/src/main/java/**/*.java",
   
],


    dxflags
: [                        // not sure if i need this, but it didn't work
       
"--core-library",
       
"--multi-dex",
   
],


    optimize
: {
        proguard_flags_files
: [
           
"lib/src/main/proguard-rules.pro",
       
],
   
},




    vendor
: true,  // not sure if i need this but it didn't work
    dex_preopt
: {  // not sure if i need this but it didn't work
        app_image
: true,
   
},
}





I also added some of the classes to "preloaded-classes"  under frameworks/base/config/preloaded-classes


When i create a new AOSP build, i can see that the classes that i put into this "preloaded-classes" file are not exposed:


W/Zygote: Class not found for preloading: com.sample.myCustomLibrary.sampleClass1
W/Zygote: Class not found for preloading: com.sample.myCustomLibrary.sampleClass2
W/Zygote: Class not found for preloading: com.sample.myCustomLibrary.sampleClass3

and i added the package to the /build/make/core/tasks/check_boot_jars/package_whitelist.txt

com\.sample\.myCusomLibrary

though i can't get my classes inside my pacakge to show up on the default class path.

Any ideas on the missing steps i need to take?

thanks!


Colin Cross

unread,
Apr 15, 2019, 12:48:37 PM4/15/19
to android-...@googlegroups.com
You can set PRODUCT_BOOT_JARS in your product makefile to add a jar to the bootclasspath, but I'd suggest providing it as a library that the apps that need it can load.

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

Elliott Mazzuca

unread,
Apr 15, 2019, 2:20:05 PM4/15/19
to Android Building
Thaks for the fast reply Colin!

I tried adding the suggested change into my local Android.mk file and now i get the following issue:

vendor/xxxx/sample/mycustomelib/apk/anotherSampelFolder/Android.mk:20: error: cannot assign to readonly variable: PRODUCT_BOOT_JARS


why is this considered a readonly variable?  is there a prerequisite step i need to do before setting this?

thanks again!

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,
Apr 15, 2019, 3:14:10 PM4/15/19
to android-...@googlegroups.com
PRODUCT_BOOT_JARS can't be set in your Android.mk, it has to be set in your product makefiles that are selected by your lunch target.  


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.

Elliott Mazzuca

unread,
Apr 16, 2019, 10:30:02 AM4/16/19
to Android Building
Thanks for the help Colin,

that did the trick for me!

Chari Veera

unread,
Sep 6, 2019, 10:07:52 AM9/6/19
to Android Building
Hello Colin,

I am able to add my jar to PRODUCT_BOOT_JARS, but I am facing following error. Do I miss anything?


Parsing out/target/product/msm8953_64/obj/ETC/vendor_sepolicy.cil_intermediates/vendor_policy_raw.cil

[ 59% 7673/12956] target dex2oat: out/target/product/msm8953_64/dex_bootjars/system/framework/arm64/boot.art

FAILED: out/target/product/msm8953_64/dex_bootjars/system/framework/arm64/boot.art

/bin/bash -c "(mkdir -p out/target/product/msm8953_64/symbols/system/framework/arm64/ ) && (rm -f out/target/product/msm8953_64/dex_bootjars/system/framework/arm64//*.art out/target/product/msm8953_64/dex_bootjars/system/framework/arm64//*.oat out/target/product/msm8953_64/dex_bootjars/system/framework/arm64//*.art.rel ) && (rm -f out/target/product/msm8953_64/symbols/system/framework/arm64//*.art ) && (rm -f out/target/product/msm8953_64/symbols/system/framework/arm64//*.oat ) && (rm -f out/target/product/msm8953_64/symbols/system/framework/arm64//*.art.rel ) && (ANDROID_LOG_TAGS=\"*:e\" out/host/linux-x86/bin/dex2oatd --runtime-arg -Xms64m   --runtime-arg -Xmx64m   --compiler-filter=speed-profile --profile-file=out/target/product/msm8953_64/dex_bootjars/system/framework/boot.prof   --dex-file=out/target/common/obj/JAVA_LIBRARIES/com.nxp.nfc.nq_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/qcom.fmradio_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/com.qualcomm.qti.camera_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/QPerformance_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/UxPerformance_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/core-oj_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/apache-xml_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/voip-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/android.hidl.base-V1.0-java_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/android.hidl.manager-V1.0-java_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/qolib_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/framework-oahl-backward-compatibility_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/android.test.base_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/tcmiface_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/WfdCommon_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/oem-services_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/telephony-ext_intermediates/javalib.jar   --dex-location=/system/framework/com.nxp.nfc.nq.jar --dex-location=/system/framework/qcom.fmradio.jar --dex-location=/system/framework/com.qualcomm.qti.camera.jar --dex-location=/system/framework/QPerformance.jar --dex-location=/system/framework/UxPerformance.jar --dex-location=/system/framework/core-oj.jar --dex-location=/system/framework/core-libart.jar --dex-location=/system/framework/conscrypt.jar --dex-location=/system/framework/okhttp.jar --dex-location=/system/framework/bouncycastle.jar --dex-location=/system/framework/apache-xml.jar --dex-location=/system/framework/ext.jar --dex-location=/system/framework/framework.jar --dex-location=/system/framework/telephony-common.jar --dex-location=/system/framework/voip-common.jar --dex-location=/system/framework/ims-common.jar --dex-location=/system/framework/android.hidl.base-V1.0-java.jar --dex-location=/system/framework/android.hidl.manager-V1.0-java.jar --dex-location=/system/framework/qolib.jar --dex-location=/system/framework/framework-oahl-backward-compatibility.jar --dex-location=/system/framework/android.test.base.jar --dex-location=/system/framework/tcmiface.jar --dex-location=/system/framework/WfdCommon.jar --dex-location=/system/framework/oem-services.jar --dex-location=/system/framework/telephony-ext.jar   --oat-symbols=out/target/product/msm8953_64/symbols/system/framework/arm64/boot.oat   --oat-file=out/target/product/msm8953_64/dex_bootjars/system/framework/arm64/boot.oat   --oat-location=/system/framework/arm64/boot.oat   --image=out/target/product/msm8953_64/dex_bootjars/system/framework/arm64/boot.art --base=0x70000000   --instruction-set=arm64   --instruction-set-variant=generic   --instruction-set-features=default   --android-root=out/target/product/msm8953_64/system   --runtime-arg -Xnorelocate --compile-pic   --no-generate-debug-info --generate-build-id   --multi-image --no-inline-from=core-oj.jar   --abort-on-hard-verifier-error   --abort-on-soft-verifier-error    --generate-mini-debug-info     || ( echo \"ERROR: Dex2oat failed to compile a boot image. It is likely that the boot classpath is inconsistent. Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS=\"--runtime-arg -verbose:verifier\" to see verification errors.\" ; false ) &&  ANDROID_LOG_TAGS=\"*:e\" ANDROID_ROOT=out/target/product/msm8953_64/system ANDROID_DATA=out/target/product/msm8953_64/dex_bootjars/system/framework/arm64/ out/host/linux-x86/bin/patchoatd   --input-image-location=out/target/product/msm8953_64/dex_bootjars/system/framework/boot.art   --output-image-relocation-directory=out/target/product/msm8953_64/dex_bootjars/system/framework/arm64/   --instruction-set=arm64   --base-offset-delta=0x10000000 )"

dex2oatd F 09-05 16:54:32  3562  3562 compiler_driver.cc:942] Had 9 soft failure(s) verifying all classes, and was asked to abort in such situations. Please check the log.

ERROR: Dex2oat failed to compile a boot image. It is likely that the boot classpath is inconsistent. Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS=--runtime-arg -verbose:verifier to see verification errors.

[ 59% 7718/12956] target dex2oat: out/target/product/msm8953_64/dex_bootjars/system/framework/arm/boot.art

FAILED: out/target/product/msm8953_64/dex_bootjars/system/framework/arm/boot.art

/bin/bash -c "(mkdir -p out/target/product/msm8953_64/symbols/system/framework/arm/ ) && (rm -f out/target/product/msm8953_64/dex_bootjars/system/framework/arm//*.art out/target/product/msm8953_64/dex_bootjars/system/framework/arm//*.oat out/target/product/msm8953_64/dex_bootjars/system/framework/arm//*.art.rel ) && (rm -f out/target/product/msm8953_64/symbols/system/framework/arm//*.art ) && (rm -f out/target/product/msm8953_64/symbols/system/framework/arm//*.oat ) && (rm -f out/target/product/msm8953_64/symbols/system/framework/arm//*.art.rel ) && (ANDROID_LOG_TAGS=\"*:e\" out/host/linux-x86/bin/dex2oatd --runtime-arg -Xms64m --runtime-arg -Xmx64m   --compiler-filter=speed-profile --profile-file=out/target/product/msm8953_64/dex_bootjars/system/framework/boot.prof   --dex-file=out/target/common/obj/JAVA_LIBRARIES/com.nxp.nfc.nq_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/qcom.fmradio_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/com.qualcomm.qti.camera_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/QPerformance_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/UxPerformance_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/core-oj_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/apache-xml_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/voip-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/android.hidl.base-V1.0-java_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/android.hidl.manager-V1.0-java_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/qolib_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/framework-oahl-backward-compatibility_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/android.test.base_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/tcmiface_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/WfdCommon_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/oem-services_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/telephony-ext_intermediates/javalib.jar   --dex-location=/system/framework/com.nxp.nfc.nq.jar --dex-location=/system/framework/qcom.fmradio.jar --dex-location=/system/framework/com.qualcomm.qti.camera.jar --dex-location=/system/framework/QPerformance.jar --dex-location=/system/framework/UxPerformance.jar --dex-location=/system/framework/core-oj.jar --dex-location=/system/framework/core-libart.jar --dex-location=/system/framework/conscrypt.jar --dex-location=/system/framework/okhttp.jar --dex-location=/system/framework/bouncycastle.jar --dex-location=/system/framework/apache-xml.jar --dex-location=/system/framework/ext.jar --dex-location=/system/framework/framework.jar --dex-location=/system/framework/telephony-common.jar --dex-location=/system/framework/voip-common.jar --dex-location=/system/framework/ims-common.jar --dex-location=/system/framework/android.hidl.base-V1.0-java.jar --dex-location=/system/framework/android.hidl.manager-V1.0-java.jar --dex-location=/system/framework/qolib.jar --dex-location=/system/framework/framework-oahl-backward-compatibility.jar --dex-location=/system/framework/android.test.base.jar --dex-location=/system/framework/tcmiface.jar --dex-location=/system/framework/WfdCommon.jar --dex-location=/system/framework/oem-services.jar --dex-location=/system/framework/telephony-ext.jar   --oat-symbols=out/target/product/msm8953_64/symbols/system/framework/arm/boot.oat   --oat-file=out/target/product/msm8953_64/dex_bootjars/system/framework/arm/boot.oat   --oat-location=/system/framework/arm/boot.oat   --image=out/target/product/msm8953_64/dex_bootjars/system/framework/arm/boot.art --base=0x70000000 --instruction-set=arm   --instruction-set-variant=cortex-a53   --instruction-set-features=default   --android-root=out/target/product/msm8953_64/system   --runtime-arg -Xnorelocate --compile-pic   --no-generate-debug-info --generate-build-id   --multi-image --no-inline-from=core-oj.jar   --abort-on-hard-verifier-error   --abort-on-soft-verifier-error    --generate-mini-debug-info     || ( echo \"ERROR: Dex2oat failed to compile a boot image. It is likely that the boot classpath is inconsistent. Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS=\"--runtime-arg -verbose:verifier\" to see verification errors.\" ; false ) &&  ANDROID_LOG_TAGS=\"*:e\" ANDROID_ROOT=out/target/product/msm8953_64/system ANDROID_DATA=out/target/product/msm8953_64/dex_bootjars/system/framework/arm/ out/host/linux-x86/bin/patchoatd   --input-image-location=out/target/product/msm8953_64/dex_bootjars/system/framework/boot.art   --output-image-relocation-directory=out/target/product/msm8953_64/dex_bootjars/system/framework/arm/   --instruction-set=arm   --base-offset-delta=0x10000000 )"

dex2oatd F 09-05 16:54:33  3559  3559 compiler_driver.cc:942] Had 9 soft failure(s) verifying all classes, and was asked to abort in such situations. Please check the log.

ERROR: Dex2oat failed to compile a boot image. It is likely that the boot classpath is inconsistent. Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS=--runtime-arg -verbose:verifier to see verification errors.

[ 59% 7723/12956] Building kernel...

make: Entering directory '/home/charid/AOSP_9/Gen4_Lucy/kernel/msm-4.9'

make[1]: Entering directory '/home/charid/AOSP_9/Gen4_Lucy/out/target/product/msm8953_64/obj/kernel/msm-4.9'

Colin Cross

unread,
Sep 6, 2019, 12:30:02 PM9/6/19
to android-...@googlegroups.com
Follow the instructions in the error and it will give you a ton more information, buried in it will be which classes it is failing to find:
ART_BOOT_IMAGE_EXTRA_ARGS="--runtime-arg -verbose:verifier" m


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/835a4245-fd94-4fe2-a9b1-72bdcc7708ad%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages