Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Bug Failed to load libmain.so

Discussion in 'Android' started by twell59, Aug 26, 2023.

  1. twell59

    twell59

    Joined:
    Feb 6, 2016
    Posts:
    25
    1. I did "File > Build Settings..." in Unity and exported an Android project.
    2. I loaded it to Android Studio.
    3. I had to uncomment the following in both build.gradle (for launcher and unityLibrary) because it wouldn't build:
    Code (CSharp):
    1. ndk {
    2. //            abiFilters 'armeabi-v7a', 'arm64-v8a'
    3. }
    4. Now it builds and opens but immediately I get this from Unity and it closes:


    I want to include Unity as a library to my native Android App but is it possible to test it in Windows 11?
     
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,678
    Most likely you require x86, x86_64 libraries, have you selected them in Player Settings?

    Also, note, Unity officially doesn't support running Android applications on Windows
     
  3. twell59

    twell59

    Joined:
    Feb 6, 2016
    Posts:
    25
    1. Does this mean I absolutely have to test all Unity exports on a real device connected to Android Studio if I want to use "Unity as a library"?

    2. Would it work on Macbook (which is arm64)?

    3. I enabled x86 and x86_64 in Player Settings and it works in Android Studio now. Thanks!

    After this change Unity modified build.gradle to include these additional options:

    Code (CSharp):
    1. ndk {
    2.             abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
    3. }
    4.  
    5. packagingOptions {
    6.     doNotStrip '*/armeabi-v7a/*.so'
    7.     doNotStrip '*/arm64-v8a/*.so'
    8.     doNotStrip '*/x86/*.so'
    9.     doNotStrip '*/x86_64/*.so'
    10. }
    11.  
     
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,678
    Yes, you can still use emulator or Windows, but if the game won't work on emulator, this will not be considered as bug.

    I don't think you can run Android apps on Mac, unless you're referring to the emulator.
     
  5. twell59

    twell59

    Joined:
    Feb 6, 2016
    Posts:
    25
    Thanks, but I think this may be actually a bug: Android Studio claims that it's possible to run Android apps on Windows 11 in Android Studio.

    They explicitly say that "x86_64" emulator includes support for x86, x86_64, ARMv7 and ARM64 ABIs.

    Source: https://developer.android.com/studi...rm_binaries_on_android_9_and_11_system_images

    So, it seems that Unity could (and should) make it work (in Windows 11 emulators from Android Studio)?

    Testing mobile phones, tables, foldables etc. is only possible via Android Studio emulators, so don't you think this is an important feature for Unity to have? (Unity's emulators are not as good as AS emulators, so no workarounds are available.)

    Yes, I'm referring to installing Android Studio on Macbook and using their emulator (which would be ARM64). Ok, never mind, I'll test it myself.