"libmain.so" not found when XR interaction toolkit is used (as Android library)

This issue involves AR, Android and Unity as a Library

“libmain.so not found” error is displayed when building a project with Unity as a Library for Android.

How to reproduce:

If some other export (unity as library for android) is generated with the same Unity 2020.2b and attached to the sample code as a library, it works.

Unity 2020.2b2 Windows 10
Android Studio Android Studio 4.0.1
Build #AI-193.6911.18.40.6626763, built on June 25, 2020
Runtime version: 1.8.0_242-release-1644-b01 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1237M
Cores: 12
Registry: ide.new.welcome.screen.force=true
Non-Bundled Plugins: com.google.services.firebase

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.unity.mynativeapp:Unity, PID: 7701
java.lang.UnsatisfiedLinkError: dlopen failed: library "/data/app/com.unity.mynativeapp-dKUmHF3qDo8UGC74BxpWSA==/lib/arm64/libmain.so" not found
at java.lang.Runtime.load0(Runtime.java:938)
at java.lang.System.load(System.java:1631)
at com.unity3d.player.UnityPlayer.loadNative(Unknown Source:18)
at com.unity3d.player.UnityPlayer.<init>(Unknown Source:164)
at com.unity3d.player.UnityPlayerActivity.onCreate(UnityPlayerActivity.java:41)
at com.company.product.OverrideUnityActivity.onCreate(OverrideUnityActivity.java:16)
at com.unity.mynativeapp.MainUnityActivity.onCreate(MainUnityActivity.java:16)
at android.app.Activity.performCreate(Activity.java:7955)
at android.app.Activity.performCreate(Activity.java:7944)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3423)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2147)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7814)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)

Any help how to make AR examples work “as a library” for Android is greatly needed! Thank you!

Hi @andreyib ,

We received your bug report and will look into it. For future references, please share related bug IDs when discussing issues on the forum (1280348).

Any news regarding this issue?

Having the same issue, using AR foundation after upgrading to 2020.2 (from 2020.1).

We weren’t able to reproduce the issue locally yet. It would be much appreciated if you could submit bug reports with reproduction steps and reproduction projects attached.

Hello @LeonhardP , I’ve created a self-contained project demonstrating the bug and attached it to my bug report 1321977 on FogBugz. Hope it gets looked at soon since it’s a show stopper.

1 Like

I am facing the same issue, I am using Unity 2020.2.7f1. I am attempting to export it as a library to use it in a native android application.

Thank you for the report and repro @vl4dimir , we’ll look into it.

1 Like

Update:

The cause of the issue was identified and fixed. The fix is on it’s way to 2020.3, 2021.1 and 2021.2.

I’ve upgraded the project to 2021.1.1f1 and the bug is still there.

Could someone please check out my minimal Github repo which demonstrates the bug and see if they’re getting the same error when running on the device? You can open the /uaal-bug-native folder from Android Studio and run it. The project is exported from the Unity project (at /uaal-bug-unity) into the /uaal-bug-native/unityAndroidBuild folder. The git log shows the sequence of steps I took to get there.

The fix landed in 2021.1.2f1. Could you please check that version?

Once a fix for an issue has landed, its Issue Tracker page will show you where.
7033876--833647--2021-04-13_13-02-00.png

@LeonhardP I’ve updated the repository to Unity 2021.1.3f1 and I’m still seeing the bug. I’m using a Samsung S7 to test. I’d love to help squash this if you can point me in the right direction.

You did the right thing by replying to your bug report email conversation. QA will pick it up again.

1 Like