Moving native libraries from android app to system lib and accessing it from app

一个人想着一个人 提交于 2019-12-12 03:05:44

问题


I have compiled one native code with android ndk. Now instead of keeping that library as part of .apk i want install it in android system (system/lib64) and my application load from system. I pushed the library to the system/lib64 and deleted the libraries from the android application's lib folder. But when i try to run i am getting

"java.lang.UnsatisfiedLinkError: dlopen failed: library "something.so" not found"

Following is my makefile

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := eng
LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/Include
LOCAL_SRC_FILES := ABCProtocol/ABCProtocol.c ABCProtocol/DatalinkLayer.c ABCProtocol/PhysicalLayer.c
LOCAL_MODULE := libABCXYZProtocol
include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := eng
LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/$(KERNEL_DIR)/include $(LOCAL_PATH)/Include $(LOCAL_PATH)/Util $(LOCAL_PATH)/Include/Linux/XYZ $(LOCAL_PATH)/ABCProtocol
LOCAL_SRC_FILES := Linux/XYZ/ABCXYZLinux.c Util/Util.c Util/Logger.c
#LOCAL_CFLAGS += -Wno-error=format-security
LOCAL_CFLAGS += -w
LOCAL_MODULE := libABCXYZWrapper
LOCAL_SHARED_LIBRARIES :=libABCXYZProtocol
include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS) 
LOCAL_MODULE_TAGS := eng
LOCAL_MODULE:=com_example_reader_ABCXYZappnote_NativeLibrary
LOCAL_SRC_FILES:=com_example_reader_ABCXYZappnote_NativeLibrary.c
LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/$(KERNEL_DIR)/include $(LOCAL_PATH)/Include $(LOCAL_PATH)/Util $(LOCAL_PATH)/Include/Linux/XYZ
#LOCAL_CFLAGS += -DANDROID
LOCAL_SHARED_LIBRARIES:=libc libABCXYZWrapper libABCXYZProtocol
include $(BUILD_SHARED_LIBRARY)

回答1:


Applications are not allowed to access non-public APIs from system library locations: https://developer.android.com/about/versions/nougat/android-7.0-changes.html#ndk. Libraries used by your app must be packaged with your app.

Why do you want to put them in /system/lib anyway?



来源:https://stackoverflow.com/questions/39853702/moving-native-libraries-from-android-app-to-system-lib-and-accessing-it-from-app

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