I'm trying to add my custom package to AOSP under frameworks/opt/mypackage
.
I provided an Android.mk
Makefile with the following content:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := mypackage
include $(BUILD_JAVA_LIBRARY)
In an other framework, I was out to use this package. For example in the telephony package.
But unfortunately the telephony framework is not able to use my package. I added my package to the LOCAL_JAVA_LIBRARIES
variable in telephony's Android.mk
but when the code is executed it gives me 01-11 16:51:01.835: E/AndroidRuntime(1789): java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
Did I miss something?
EDIT: setting include $(BUILD_STATIC_JAVA_LIBRARY)
instead of include $(BUILD_JAVA_LIBRARY)
in my Makefile and adding my package to the LOCAL_STATIC_JAVA_LIBRARIES
of the frameworks works well. Nevertheless: the question is why does it not work with a non-static library.
To use a Java library (JAR file) inside your Android project, you can simple copy the JAR file into the folder called libs in your application. *. jar files in this folder are included into the compile classpath via the default build.
It's because you need a permission file for local libraries.
Follow these steps:
add your lib name "mypackage" to LOCAL_JAVA_LIBRARIES
in your Android.mk of the package you want to use it.
add the xml permission file like this:
com.mypackage.platform_library.xml
<?xml version="1.0" encoding="utf-8"?>
<permissions>
<library name="com.mypackage.platform_library"
file="/system/framework/com.mypackage.platform_library.jar"/>
</permissions>
This file must be placed in /system/etc/permissions on the device. Make also sure that your mypackage.jar is at the specified location on the device.
<uses-library android:name="com.mypackage.platform_library" />
Here you can find an example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With