Search Unity

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

Discussion in '2020.2 Beta' started by andreyib, Sep 25, 2020.

  1. andreyib

    andreyib

    Joined:
    Jul 3, 2020
    Posts:
    10
    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:
    - Use Unity as a library for Android example:
    https://github.com/Unity-Technologies/uaal-example/blob/master/docs/android.md
    - Generate an export from scenes/ux/sampleuxscene scene
    https://github.com/Unity-Technologies/arfoundation-samples
    Using default settings with the project (IL2CPP, v7 ,64)
    If to install to the device straight from Unity 2020.2b, it works. If embeded in the example code, it does not. It throws the error if built via Android studio with Android Studio SDK, NDK.

    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!
     
  2. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,491
    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).
     
  3. KangiClub

    KangiClub

    Joined:
    May 12, 2019
    Posts:
    3
    Any news regarding this issue?
     
  4. chenklein

    chenklein

    Joined:
    Aug 11, 2012
    Posts:
    13
    Having the same issue, using AR foundation after upgrading to 2020.2 (from 2020.1).
     
  5. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,491
    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.
     
  6. vl4dimir

    vl4dimir

    Joined:
    Jun 28, 2012
    Posts:
    18
    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.
     
    LeonhardP likes this.
  7. RJSD3V

    RJSD3V

    Joined:
    Aug 30, 2019
    Posts:
    3
    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.
     
  8. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,491
    Thank you for the report and repro @vl4dimir, we'll look into it.
     
    vl4dimir likes this.
  9. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,491
  10. vl4dimir

    vl4dimir

    Joined:
    Jun 28, 2012
    Posts:
    18
    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.
     
  11. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,491
    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.
    2021-04-13_13-02-00.png
     
  12. vl4dimir

    vl4dimir

    Joined:
    Jun 28, 2012
    Posts:
    18
    @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.
     
  13. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,491
    You did the right thing by replying to your bug report email conversation. QA will pick it up again.
     
    vl4dimir likes this.
unityunity