RK3399 android_deploy demo cant't find libGLES_mali.so

my android deploy app can’t find “libGLES_mali.so” (can be found in the /system/vendor/lib64/egl/libGLES_mali.so)

the flowing is my configuration

APP_ABI = arm64-v8a

APP_PLATFORM = android-17

# whether enable OpenCL during compile
USE_OPENCL = 1

# the additional include headers you want to add, e.g., SDK_PATH/adrenosdk/Development/Inc
ADD_C_INCLUDES = CL

# the additional link libs you want to add, e.g., ANDROID_LIB_PATH/libOpenCL.so
ADD_LDLIBS = libOpenCL.so #copy from /system/vendor/lib64/libOpenCL.so

the following is the error log

08-03 06:02:10.636   274   289 E BufferQueueProducer: [com.android.launcher3/com.android.launcher3.Launcher#0] disconnect: not connected (req=1)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
08-03 06:02:12.366  2145  2167 E AndroidRuntime: Process: ml.dmlc.tvm.android.demo, PID: 2145
08-03 06:02:12.366  2145  2167 E AndroidRuntime: java.lang.RuntimeException: An error occurred while executing doInBackground()
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at android.os.AsyncTask$3.done(AsyncTask.java:353)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at java.util.concurrent.FutureTask.run(FutureTask.java:271)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at java.lang.Thread.run(Thread.java:764)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: Caused by: java.lang.ExceptionInInitializerError
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at ml.dmlc.tvm.Function.listGlobalFuncNames(Function.java:52)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at ml.dmlc.tvm.Function.getFunction(Function.java:38)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at ml.dmlc.tvm.Module.getApi(Module.java:41)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at ml.dmlc.tvm.Module.load(Module.java:139)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at ml.dmlc.tvm.Module.load(Module.java:145)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at ml.dmlc.tvm.android.demo.MainActivity$LoadModleAsyncTask.doInBackground(MainActivity.java:184)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at ml.dmlc.tvm.android.demo.MainActivity$LoadModleAsyncTask.doInBackground(MainActivity.java:124)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at android.os.AsyncTask$2.call(AsyncTask.java:333)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	... 4 more
08-03 06:02:12.366  2145  2167 E AndroidRuntime: Caused by: java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: dlopen failed: library "libGLES_mali.so" not found
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at ml.dmlc.tvm.Base.<clinit>(Base.java:85)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	... 13 more
08-03 06:02:12.366  2145  2167 E AndroidRuntime: **Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libGLES_mali.so" not found**
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at java.lang.System.loadLibrary(System.java:1657)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	at ml.dmlc.tvm.Base.<clinit>(Base.java:80)
08-03 06:02:12.366  2145  2167 E AndroidRuntime: 	... 13 more

I found a solution, create a library directory, put all related libraries(pull from rk3399) in, and then reference the directory in gradle.

This method solves the library loading problem, but there are still other problems running in my RK3399. When the “run” method is executed, the system throws an exception.

E/libc++abi: terminating with uncaught exception of type dmlc::Error: [05:36:28] /Users/dinghuanghao/Project/tvm/apps/android_deploy/app/src/main/jni/jni_helper_func.h:194: Do NOT know how to handle return type code 1044873685
A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 2097 (AsyncTask #2), pid 2049 (vm.android.demo)

It may be a little late. Android doesn’t allow vendor libraries to be loaded as they belong to different classloader namespace. Instead google recommends to package all the required vendor private libraries with the app. https://developer.android.com/about/versions/nougat/android-7.0-changes.html#ndk