添加.so库作为AOSP Lollipop中包/应用程序的一部分

时间:2015-09-09 06:21:55

标签: android-source android.mk

我一直在尝试将.so库作为我的应用程序的一部分包含在AOSP中。它可以用Android.mk完成。以下是我在pacakges / app目录中的应用程序的Android.mk:

 LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS)

 LOCAL_MODULE_TAGS := optional

 LOCAL_SRC_FILES := $(call all-java-files-under, src)

 LOCAL_PACKAGE_NAME := OpentokSample  
 LOCAL_CERTIFICATE:= platform

 LOCAL_JNI_SHARED_LIBRARIES=libopentok

 include $(BUILD_PACKAGE)

 include $(call all-makefiles-under,$(LOCAL_PATH))

以下是Android.mk以包含libopentok.so:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libopentok
LOCAL_PREBUILT_LIBS := opentok.so
include $(BUILD_SHARED_LIBRARY)

但是这没有帮助吗?

2 个答案:

答案 0 :(得分:2)

如果您使用预先构建的.so文件,我认为您应该使用include $(BUILD_PREBUILT),并将其标记为LOCAL_MODULE_CLASS := SHARED_LIBRARIES。您需要在LOCAL_REQUIRED_MODULES中列出依赖项。

下面是一个示例 Android.mk ,它添加了一个预编译的apk应用程序,并将其.so库放入系统lib文件夹中:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_MODULE := MyApp

LOCAL_CERTIFICATE := platform

LOCAL_REQUIRED_MODULES := libamrcodec libecies

LOCAL_SRC_FILES := MyApp.apk

LOCAL_MODULE_CLASS := APPS

LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)

include $(BUILD_PREBUILT)

include $(CLEAR_VARS)
LOCAL_MODULE := libamrcodec
LOCAL_SRC_FILES := libs/armeabi/libamrcodec.so
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_PRELINK_MODULE := false
#LOCAL_MODULE_PATH := system/lib
include $(BUILD_PREBUILT)

include $(CLEAR_VARS)
LOCAL_MODULE := libecies
LOCAL_SRC_FILES := libs/armeabi/libecies.so
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_PRELINK_MODULE := false
#LOCAL_MODULE_PATH := system/lib
include $(BUILD_PREBUILT)

答案 1 :(得分:0)

LOCAL_MODULE_TAGS := samples

LOCAL_MODULE_TAGS := tests