0

I am trying to add both Dlib and superpowers libraries to my android project using Android.mk. I included successfully prebuilt shared Dlib library (.so files) using Android.mk, but when I am trying to add the superpower as a static library (the package has .a files and CMakeLists.txt), I am facing issue regarding liking JNI functions with java. I cannot use the JNI functions in java. I would appreciate it if someone can help me. Here is my Android.mk file:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := libs
LOCAL_SRC_FILES := /[MyProjectAddress]/app/libs/$(TARGET_ARCH_ABI)/libdlib.so
LOCAL_EXPORT_C_INCLUDES := /[MyDLIBFileAddress]/dlib_v19.7/dlib
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := superpoweredLib
LOCAL_SRC_FILES := /[MyProjectAddress]/app/libs/$(TARGET_ARCH_ABI)/libSuperpoweredAndroid$(TARGET_ARCH_ABI).a
LOCAL_EXPORT_C_INCLUDES := /[SuperpoweredFileAddress]/SuperpoweredSDK/Superpowered/AndroidIO/SuperpoweredAndroidAudioIO.cpp \ /[SuperpoweredFileAddress]/SuperpoweredSDK/Superpowered \ 
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := FrequencyDomain
LOCAL_LDFLAGS := -Wl,--build-id
LOCAL_LDLIBS += -llog -ldl
LOCAL_SRC_FILES := \ /[MyProjectAddress]/app/src/main/jni/FrequencyDomain.cpp \

LOCAL_C_INCLUDES += /[MyProjectAddress]/app/src/debug/jni                 
LOCAL_C_INCLUDES += /[MyProjectAddress]/app/src/main/jni

LOCAL_SHARED_LIBRARIES := libs
include $(BUILD_SHARED_LIBRARY)

LOCAL_SHARED_LIBRARIES := superpoweredLib
include $(BUILD_SHARED_LIBRARY)
Breeze
  • 1
  • 2
  • What's with the two `include $(BUILD_SHARED_LIBRARY)` lines at the end? I.e. what is the second one supposed to do? – Michael Feb 12 '18 at 16:30
  • I am new to Android studio and I thought that for adding each library, I need to write include $(BUILD_SHARED_LIBRARY). – Breeze Feb 12 '18 at 16:52
  • No, `include $(BUILD_SHARED_LIBRARY)` is what you do when you want to build a shared library. You only have one such library (FrequencyDomain). So you should probably also combine the two `LOCAL_SHARED_LIBRARIES` lines into a single line. – Michael Feb 12 '18 at 16:55
  • I modified it based on your comment: LOCAL_SHARED_LIBRARIES := libs superpoweredLib FrequencyDomain, the project built successfully, but All the functions from FrequencyDomain.cpp in java are shown in red and apparently I cannot use them. – Breeze Feb 12 '18 at 18:15
  • More than likely that's just an IDE thing, and your app will work just fine (assuming there are no bugs in the actual code). You could try looking into making your IDE recognize your native functions if you want to, but it's not really necessary for build the app. – Michael Feb 12 '18 at 18:41
  • @Breeze even I am working on SuperPower library and I am also stuck with the same issue. Could you please help me to understand how to add superPower library with a existing native lib. I am new to native and I am not able to understand what all parameters i need to pass to Android.mk for superpower library. And what all i have to do to use superpower with an existing native lib. – ayush bagaria Mar 21 '18 at 15:40

0 Answers0