In Android souce code (AOSP), I am trying to compile a jar library into /vendor/framework/ but not /system/framework.
So I did the change in Android.bp for this library:
java_library {
name: "com.test.provider",
srcs: ["./java/**/*.java"],
vendor: true,
dex_preopt: {
app_image: true,
},
}
The com.test.provider.jar was built to /vendor/framework/ now.
Then I use this library in SystemUI, did the change in frame/base/packages/SystemUI/Android.mk:
LOCAL_JAVA_LIBRARIES += com.test.provider
And also refer the class that defined in com.test.provider.jar, SystemUI was built successful.
But when this APP was running, got the below error message:
12-27 11:35:41.807 5449 5449 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
12-27 11:35:41.807 5449 5449 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.test.testprovidermanager.TestProviderManager" on path: DexPathList[[zip file "/system/priv-app/SystemUI/SystemUI.apk"],nativeLibraryDirectories=[/system/priv-app/SystemUI/lib/arm64, /system/lib64, /vendor/lib64, /system/lib64, /vendor/lib64]]
Looks like OS seeks this library neither /system/framework nor /vendor/framework. But when I built this library to /system/framework/(Remove "vendor: true" from Android.bp), SystemUI works fine, it is so strange!
So my question is: How to build a jar library to /vendor/framwork/ in Android P?
Thanks for your help!
Sloved this issue. I forgot change permission in /system/etc/permission/testprovider_permission.xml:
<?xml version="1.0" encoding="utf-8"?>
<permissions>
<library name="com.test.provider"
file="/system/framework/com.test.provider.jar"/>
</permissions>
Change /system/framework/com.test.provider.jar to /vendor/framework/com.test.provider.jar