【问题标题】:JNI integration into AOSP buildJNI 集成到 AOSP 构建中
【发布时间】:2014-04-25 22:59:39
【问题描述】:

我需要通过添加一些自定义库来更改设置应用程序,但我遇到了配置问题。当我尝试调用 System.loadLibrary("mylibrary") 时,我得到 libraryPath=/data/app-lib/com.settings-1: find library returned null。我知道该应用程序会在 /data/app-lib/.. 文件夹中查找特定库,但我的库位于 system/lib 中

我知道我的 .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))

jni文件夹中的.mk文件

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)

【问题讨论】:

    标签: android android-ndk makefile java-native-interface android-source


    【解决方案1】:

    我意识到我必须在我的库中添加前缀“lib”,以便从系统/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,因为它永远不会被使用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-18
      • 1970-01-01
      • 2022-01-03
      • 2013-12-12
      • 1970-01-01
      • 1970-01-01
      • 2023-03-29
      • 2018-06-09
      相关资源
      最近更新 更多