f111fei / react-native-unity-demo

103 stars 80 forks source link

Crashes on Android due to error "libmain.so not found" with RN > 0.60 #42

Closed itinance closed 4 years ago

itinance commented 4 years ago

While everything works fine with React Native below any version under 0.60 (and already reported at As already reported in https://github.com/f111fei/react-native-unity-view/issues/142), on Android the application will crash upon activating the UnityView with RN > 0.60.

The final error happens because of a "libmain.so" could not be loaded:

E Unity   : Failed to load 'libmain.so', the application will terminate.
D AndroidRuntime: Shutting down VM
E AndroidRuntime: FATAL EXCEPTION: main
E AndroidRuntime: Process: com.rnunitydemo, PID: 16887
E AndroidRuntime: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.rnunitydemo-bKGyotdcwjVnBxuR9zLE4Q==/base.apk"],nativeLibraryDirectories=[/data/app/com.rnunitydemo-bKGyotdcwjVnBxuR9zLE4Q==/lib/arm64, /data/app/com.rnunitydemo-bKGyotdcwjVnBxuR9zLE4Q==/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]]] couldn't find "libmain.so"

According to a crash-report in the official Unity-Forum, we took care to use the same settings in both build.gradle for ndk-abiFilter:

android {
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 28
        ndk {
            abiFilters 'armeabi-v7a', 'x86'
        }
        multiDexEnabled true
        versionCode 1
        versionName '0.1'
    }
}

but it won't fix the issue. There is a big chance that the issues https://github.com/f111fei/react-native-unity-view/issues/120 and https://github.com/f111fei/react-native-unity-view/issues/129 might be related to this one.

Anybody found a proper solution for this?

itinance commented 4 years ago

Solution: https://github.com/f111fei/react-native-unity-view/issues/142#issuecomment-557162700