Adding own framework or library to AOSP

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 10:20:18

问题


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.


回答1:


It's because you need a permission file for local libraries.

Follow these steps:

  1. add your lib name "mypackage" to LOCAL_JAVA_LIBRARIES in your Android.mk of the package you want to use it.

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

  1. In your AndroidManifest use <uses-library android:name="com.mypackage.platform_library" />

Here you can find an example.



来源:https://stackoverflow.com/questions/27889193/adding-own-framework-or-library-to-aosp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!