向AOSP添加自己的框架或库 [英] Adding own framework or library to AOSP

查看:248
本文介绍了向AOSP添加自己的框架或库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将自定义软件包添加到frameworks/opt/mypackage下的AOSP.

我提供了一个Android.mk Makefile,其内容如下:

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)

在另一个框架中,我无法使用此程序包.例如,在电话包中.

但是不幸的是,电话框架无法使用我的程序包.我将程序包添加到电话Android.mkLOCAL_JAVA_LIBRARIES变量中,但是当执行代码时,它给了我01-11 16:51:01.835: E/AndroidRuntime(1789): java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

我错过了什么吗?

在我的Makefile中设置include $(BUILD_STATIC_JAVA_LIBRARY)而不是include $(BUILD_JAVA_LIBRARY)并将我的包添加到框架的LOCAL_STATIC_JAVA_LIBRARIES效果很好.但是:问题是为什么它不能与非静态库一起使用.

解决方案

这是因为您需要本地库的权限文件.

请按照以下步骤操作:

  1. 将您的库名称"mypackage"添加到要使用的软件包的Android.mk中的LOCAL_JAVA_LIBRARIES中.

  2. 添加xml许可文件,如下所示:

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>

此文件必须放在设备上的/system/etc/permissions中.还要确保mypackage.jar位于设备上的指定位置.

  1. 在您的AndroidManifest中使用<uses-library android:name="com.mypackage.platform_library" />

此处,您可以找到一个示例. >

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.

解决方案

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.

这篇关于向AOSP添加自己的框架或库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆