question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 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?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
itinancecommented, Nov 21, 2019

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”

0reactions
KainanSucommented, 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”

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve "libmain.so not found" while using Unity as a ...
I can answer by myself now. The issue was caused by Unity export that was not ARM64-compatible unless several settings were applied manually ......
Read more >
App not working on some devices; Failed to load 'libmain.so'
I've been experiencing this "libmain.so" error on Android 9+ devices with Unity 2020.2.1f1 and 2020.2.2f1, while older Android versions were ...
Read more >
android - React-Native :java.lang.UnsatisfiedLinkError: couldn't find ...
I have just updated my project to use react-native version 0.60.2 . But when I am trying to run an application on Android...
Read more >
[Android] App installed using APK from app bundle option in ...
bugexportproject-9BuOMuJaMXjG4oK6dLN3SQ==/lib/arm/libmain.so" not found Press Ok to quit." Reproducible with: 2020.2.0a12, 2020.2.7f1, 2021.1.
Read more >
Bluestacks 5 - "Your hardware does not support this ... - Reddit
Hi, I'm getting these error messages when I try to run a game. I downloaded the APK file directly instead of using the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found