JNI整合到AOSP构建中

 2023-01-19    359  

问题描述

我需要通过向其添加一些自定义库来更改设置应用程序,但是我在配置方面存在问题.当我尝试调用system.loadlibrary(” mylibrary”)时,我会得到librarypath =/data/app-lib/com.settings-1:查找库返回null.我知道该应用将在内部/data/app-lib/..文件夹中查看特定库的文件夹,但我的库在System/Lib

JNI整合到AOSP构建中

我知道我的.mk文件不好,但我不知道我缺少什么,请看一下它们.

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

LOCAL_JAVA_LIBRARIES := bouncycastle telephony-common
LOCAL_STATIC_JAVA_LIBRARIES := guava android-support-v4 jsr305
ifdef DOLBY_DAP
LOCAL_JAVA_LIBRARIES += framework_ext
else
LOCAL_STATIC_JAVA_LIBRARIES += libsds
endif #DOLBY_DAP

LOCAL_MODULE_TAGS := optional

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

LOCAL_PACKAGE_NAME := Settings
LOCAL_CERTIFICATE := platform

# If this is an unbundled build (to install seprately) then include
# the libraries in the APK, otherwise just put them in /system/lib and
# leave them out of the APK
ifneq (,$(TARGET_BUILD_APPS))
  LOCAL_JNI_SHARED_LIBRARIES := efuse_tool
else
  LOCAL_REQUIRED_MODULES := efuse_tool
endif

LOCAL_PROGUARD_FLAG_FILES := proguard.flags

include $(BUILD_PACKAGE)

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

ifndef DOLBY_DAP
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libsds:ds.jar
include $(BUILD_MULTI_PREBUILT)
endif

# Use the folloing include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH))

和.mk文件jni文件夹

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

# Here we give our module name and source file(s)

LOCAL_SRC_FILES := efuse_tool.c
LOCAL_MODULE    := efuse_tool
include $(BUILD_SHARED_LIBRARY)

推荐答案

我意识到我必须在库中添加前缀” lib”,因此它将从System/Lib位置调用.所以看起来应该像这样

ifneq (,$(TARGET_BUILD_APPS))
  LOCAL_JNI_SHARED_LIBRARIES := libefuse_tool
else
  LOCAL_REQUIRED_MODULES := libefuse_tool
endif


LOCAL_MODULE    := libefuse_tool

我也可以删除local_jni_shared_libraries:= libefuse_tool,因为它永远不会使用.

以上所述是小编给大家介绍的JNI整合到AOSP构建中,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对77isp云服务器技术网的支持!

原文链接:https://77isp.com/post/25856.html

=========================================

https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。