I have A problem with Loading SO Libraries Dynamically in android and in order for people to understand why I actually need to do this and maybe suggest different ways to do it I'm going to explain briefly the project. I'm working on a research project to test the benefits of code offloading the flow that I have been working on is as follows :
The user triggers a function that was predetermined to be time-consuming the process is intercepted using Xposed Hooks, The Apk of the App is sent to server then the on the server I run the method from the APK dynamically for android nougat or even oreo this won't cause any troubles as I thought but the main problem some of the apps I'm working on use non-NDK libs and this causes some problems because the system won't allow the me to load the libraries dynamically I'm required to add these libraries to my app and this doesn't work for me because I the server app is one app fit all it receives a method name apk and package name and some parameters and it should run the function with the parameters of and return the result regardless of the apk or function name so cutting to the problem directly
I need to be able to run this code without trouble the code :
val classLoader = DexClassLoader("/storage/emulated/0/ApkDir/base.apk", applicationContext.codeCacheDir.absolutePath,
"/storage/emulated/0/ApkDir/lib/arm64/" , this.javaClass.classLoader
The problems that the code raises for android oreo and above
01-15 03:19:22.729 10712-10712/com.sablab.myapplication W/b.myapplication: type=1400 audit(0.0:11387): avc: denied { execute } for path="/storage/emulated/0/APKDir/libs/libpngt.so" dev="fuse" ino=79 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:fuse:s0 tclass=file permissive=0
and if not this I get
Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: couldn't map "/storage/emulated/0/APKDir/libs/libpngt.so" segment 1: Permission denied