firefexx
firefexx

Reputation: 786

Adding own framework or library to AOSP

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.

Upvotes: 7

Views: 8435

Answers (1)

nilo
nilo

Reputation: 709

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.

Upvotes: 10

Related Questions