Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
itinance opened this issue Nov 15, 2019 · 5 comments
Closed

Comments

@itinance
Copy link

While everything works fine with React Native below any version under 0.60, 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 #120 and #129 might be related to this one.

Anybody found a proper solution for this?

@itinance
Copy link
Author

Apparently this issue is not only related to React Native and its gradle-files, but a common issue nowadays according to StackOverflow, like this: https://stackoverflow.com/questions/58751549/unable-to-load-libmain-so-in-android-studio-and-unity-as-library

@Villar74
Copy link

Confirm that problem, can't find solution

@itinance
Copy link
Author

Found it. Bevor building for Android, we need to adjust some settings in "Player Settings" in order to make ARM64 Bit available:

  • Switching "Scripting Backend" from Mono to ILCPP, which enables us to:
  • Select "ARM64" under Target Architectures

Screenshot 2019-11-21 16 12 15

If you run into an Error like "NDK not found", ensure that Unity has downloaded and installed its own copy of NDK:

Screenshot 2019-11-21 17 24 43

Having all this in mind will enable us to link against these libraries without failing to find "libmain.so"

@KainanSu
Copy link

KainanSu commented Mar 8, 2022

It works, thanks

Found it. Bevor building for Android, we need to adjust some settings in "Player Settings" in order to make ARM64 Bit available:

  • Switching "Scripting Backend" from Mono to ILCPP, which enables us to:
  • Select "ARM64" under Target Architectures
Screenshot 2019-11-21 16 12 15

If you run into an Error like "NDK not found", ensure that Unity has downloaded and installed its own copy of NDK:

Screenshot 2019-11-21 17 24 43

Having all this in mind will enable us to link against these libraries without failing to find "libmain.so"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants