My app works on a Nexus 5, Motorola Moto G4 and a tv box sex Minix Neo-X9. But when I try running it on a LG G5 or a LeEco Le2 I get the following issue:
06-28 14:24:14.869: E/AndroidRuntime(7264): FATAL EXCEPTION: main
06-28 14:24:14.869: E/AndroidRuntime(7264): Process: com.vidyo.vidyomod, PID: 7264
06-28 14:24:14.869: E/AndroidRuntime(7264): java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.vidyo.vidyomod-1/base.apk"],nativeLibraryDirectories=[/data/app/com.vidyo.vidyomod-1/lib/arm64, /data/app/com.vidyo.vidyomod-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libVidyoClientApp.so"
06-28 14:24:14.869: E/AndroidRuntime(7264): at java.lang.Runtime.loadLibrary(Runtime.java:367)
06-28 14:24:14.869: E/AndroidRuntime(7264): at java.lang.System.loadLibrary(System.java:1076)
06-28 14:24:14.869: E/AndroidRuntime(7264): at com.vidyo.VidyoClientLib.LmiAndroidAppJni.<clinit>(LmiAndroidAppJni.java:692)
06-28 14:24:14.869: E/AndroidRuntime(7264): at java.lang.Class.newInstance(Native Method)
06-28 14:24:14.869: E/AndroidRuntime(7264): at android.app.Instrumentation.newApplication(Instrumentation.java:1001)
06-28 14:24:14.869: E/AndroidRuntime(7264): at android.app.Instrumentation.newApplication(Instrumentation.java:986)
06-28 14:24:14.869: E/AndroidRuntime(7264): at android.app.LoadedApk.makeApplication(LoadedApk.java:582)
06-28 14:24:14.869: E/AndroidRuntime(7264): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5116)
06-28 14:24:14.869: E/AndroidRuntime(7264): at android.app.ActivityThread.-wrap2(ActivityThread.java)
06-28 14:24:14.869: E/AndroidRuntime(7264): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1628)
06-28 14:24:14.869: E/AndroidRuntime(7264): at android.os.Handler.dispatchMessage(Handler.java:111)
06-28 14:24:14.869: E/AndroidRuntime(7264): at android.os.Looper.loop(Looper.java:207)
06-28 14:24:14.869: E/AndroidRuntime(7264): at android.app.ActivityThread.main(ActivityThread.java:5917)
06-28 14:24:14.869: E/AndroidRuntime(7264): at java.lang.reflect.Method.invoke(Native Method)
06-28 14:24:14.869: E/AndroidRuntime(7264): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
06-28 14:24:14.869: E/AndroidRuntime(7264): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)
The code is the same, how can it work on a phone, and not work on another phone? I mean, it runs the library perfect on some, and on the others not. And I tested, for example the LeEco is 6.00 and Nexus 5 which works is 6.0.1. So I don't think this is an Android OS issue
In my jniLibs folder I have this: jniLibs->armeabi-v7a->libVidyoClientApp.so
Do I also need to have a folder like: jniLibs->arm64-v8a -> libVidyoClientApp.so or something like that? Asking because of this line:
/data/app/com.vidyo.vidyomod-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libVidyoClientApp.so"
In my build.gradle I have this:
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
}
For 64-bit devices (most of modern phones and tablets), you should supply all libraries in lib/arm64-v8a, or none. If there are no 64-bit libs, the system will happily use 32-bit version from lib/armeabi-v7a. But if there is even one 64-bit lib (often coming from some 3rd party SDK), your app will crash with UnsatisfiedLinkError.
The easiest way to control this is to set APP_ABI=armeabi-v7a
for ndb-build, usually in Application.mk file.
With Android Studio (not your case, jni.srcDirs = []
disables NDK integration), gradle overrides this. You need abiFilters in android.defaultConfig.ndk block or like this:
android {
defaultConfig {
externalNativeBuild {
cmake {
abiFilters "armeabi-v7a"
}
}
}
}
Alternatively, you can compile all your libraries for 64 bit. For some heavy computational tasks, you can get a significant performance gain with little effort. In other cases, the gain is minimal, but porting C++ code to 64 bit may be challenging work. Also, this could inflate the size of your APK significantly. If you choose to supply both 32-bit and 64-bit versions of your app, it's recommended to split the APK.
Specifically for Render Script, the chances are that performance gain will not outweigh the hassle of dealing with multiple ABIs. Note that even if you set target API below 21, gradle will copy the 64-bit RenderScript libraries.