4

I've just updated from NDK 12.x to 13.x and now I'm getting the following crash:

Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__aeabi_memcpy4" referenced by "/data/app/com.app.myapp-1/lib/arm/libJniBitmapOperationsLibrary.so"...
  at java.lang.Runtime.loadLibrary(Runtime.java:372)
  at java.lang.System.loadLibrary(System.java:1076)
  at com.jni.bitmap_operations.JniBitmapHolder.<clinit>(JniBitmapHolder.java:11)
  <...>

The library I'm using is available here.

I've seen a few similar issues on SO to do with cannot locate symbol and all the suggestions were around setting APP_PLATFORM in the Application.mk file. My JNI library is part of the SDK so I don't have Application.mk file - only Android.mk. Also my target/min sdk didn't change recently. My Android.mk file is copied from the library and looks like this:

LOCAL_PATH := $(call my-dir)

#bitmap operations module
include $(CLEAR_VARS)

LOCAL_MODULE    := JniBitmapOperationsLibrary
LOCAL_SRC_FILES := JniBitmapOperationsLibrary.cpp
LOCAL_LDLIBS := -llog
LOCAL_LDFLAGS += -ljnigraphics

include $(BUILD_SHARED_LIBRARY)
APP_OPTIM := debug
LOCAL_CFLAGS := -g
vkislicins
  • 3,181
  • 3
  • 29
  • 54

1 Answers1

1

Ok, I think I've figured out an answer with the help of JNI and Gradle in Android Studio and Android NDK : Getting java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "signal" referenced by "libffmpeg.so"

The solution for me was to do the following:

1) add Application.mk file with the following:

APP_CFLAGS += -I$(LOCAL_PATH)  
APP_ABI := all  
APP_PLATFORM := android-19 

2) update my build.gradle to point at my Application.mk as apparently gradle creates its own version of Android.mk and defaults to the same api level as you have in compileSdkVersion not minSdkVersion.

With com.android.tools.build:gradle:2.2.0 this can be achieved by adding the following (for more details check out the JNI SO post mentioned above):

externalNativeBuild {
    ndkBuild {
        path 'src/main/jni/Application.mk'
    }
}

Also, you probably don't need both steps one and two, but I've spent too much time on this already to verify

Community
  • 1
  • 1
vkislicins
  • 3,181
  • 3
  • 29
  • 54