Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,812,386 Members 38,479 Now Online
XDA Developers Android and Mobile Development Forum

JNI integration into AOSP build

Tip us?
 
damirmiljkovic
Old
#1  
Junior Member - OP
Thanks Meter 0
Posts: 2
Join Date: Apr 2014
Default JNI integration into AOSP build

I need to change Settings app by adding some custom library to it but I am having problems with configuration. When I try to call System.loadLibrary("mylibrary") i get libraryPath=/data/app-lib/com.settings-1: find library returned null. I know that app will look inside /data/app-lib/.. folder for specific library but my library is in system/lib

I know that my .mk files are not OK but I don't know what am I missing, please take look at them.

Code:
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))
And .mk file inside jni folder

Code:
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)
 
damirmiljkovic
Old
#2  
Junior Member - OP
Thanks Meter 0
Posts: 2
Join Date: Apr 2014
I realized that I have to add prefix "lib" to my library so it will be called from system/lib location. So it should look like this

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

LOCAL_MODULE := libefuse_tool
I can also remove LOCAL_JNI_SHARED_LIBRARIES := libefuse_tool because it will never be used.
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes