How to link so library from optee client app with android ndk in Android 9


#1

I developed an Android Native Apk. Firstly, I generated an so file (libmyteeapp.so) as using native library. Then, I installed it to /vendor/lib64 . Because, it uses another library (libteec.so) in /vendor/lib64 .

Secondly, I installed my app as system apk in /system/app . I call libmyteeapp.so in my code like this:

System.loadLibrary(‘myteeapp’);

But, my apk can’t load (libmyteeapp.so) library. And, Error:

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file “/system/app/MyTeeApp/MyTeeApp.apk”],nativeLibraryDirectories=[/system/app/MyTeeApp/MyTeeApp.apk/lib/arm64, /systemapp/MyTeeApp/MyTeeApp.apk!/lib/arm64-v8a, /system/lib64, /system/lib64]]] couldn’t find “libmyteeapp.so”

In previos Android version, my app worked correctly. Because, libteec.so and libmyteeapp.so are in /system/lib64 folder. So, android app could load libmyteeapp.so and this library can use libteec.so

In Android 9, libteec.so is just in /vendor/lib64 .

I searched some examples in Google. In a lot of examples, nativeLibraryDirectories includes vendor/lib64 folder. But, in my example there is no /vendor/lib64 directory. (please, look at the error)

How can I link to /vendor/lib64 directory from my app or how can Android system show /vendor/lib64 for loading library? selinux policy can block /vendor folder for loading library.