Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

App not working on some devices; Failed to load 'libmain.so'

Discussion in 'Android' started by ishimurax, Jan 1, 2021.

  1. ishimurax

    ishimurax

    Joined:
    May 7, 2020
    Posts:
    6
    After upgrading our Unity project from 2019.3.15f1 to 2020.2.1f1
    some of our testers started getting error:

    12-31 16:21:34.740 20342 20342 E Unity   : Failed to load 'libmain.so'
    12-31 16:21:34.740 20342 20342 E Unity :
    12-31 16:21:34.740 20342 20342 E Unity : java.lang.UnsatisfiedLinkError: dlopen failed: library "/data/app/com.*****.*****-2VG7SJabCDmTNFQuPiQIyw==/lib/arm64/libmain.so" not found
    12-31 16:21:34.740 20342 20342 E Unity : Your hardware does not support this application.



    We are building our project as .aab (Android App Bundle) with Google Play. When built .aab is checked with winrar, we can see that
    libmain.so is included in both ****.aab\base\lib\arm64-v8a ****.aab\base\lib\armeabi-v7a.

    By now we tried:
    - Checking our build settings are: scripting backend is IL2cpp, both ARMv7 ARM64 target architectures are checked.
    - Deleted library completely and let unity recreate it
    - Setting install location to `automatic`
    - Setting write permission to `internal`
    - Clearing play store cache and app cache for testers device

    build.gradle:

    android {
    compileSdkVersion 30
    buildToolsVersion '30.0.3'

    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
    minSdkVersion 24
    targetSdkVersion 30
    ndk {
    abiFilters 'armeabi-v7a', 'arm64-v8a'
    }
    versionCode 490
    versionName '1.490'
    consumerProguardFiles 'proguard-unity.txt'
    }

    lintOptions {
    abortOnError false
    }

    aaptOptions {
    noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
    ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    }

    packagingOptions {
    doNotStrip '*/armeabi-v7a/*.so'
    doNotStrip '*/arm64-v8a/*.so'
    }


    Graphics API: OpenGLES3

    Some packages in project

    - Facebook SDK 8.1.1
    - Backtrace 3.2.6
    - Google Play Asset Delivery & Google Play Core 1.3.0
    - Localization 0.9.0
    - AR Foundation 4.0.9
    - IAP 2.1.1
    - EMpro 2.13.0
     
  2. chenklein

    chenklein

    Joined:
    Aug 11, 2012
    Posts:
    13
    Same here
     
  3. mocerezo

    mocerezo

    Joined:
    Jan 21, 2013
    Posts:
    8
    I have the same issue
     
  4. darkmagas

    darkmagas

    Joined:
    Aug 28, 2013
    Posts:
    1
    yeah it happens also for me has anyone found a solution?, so far im thinking on going back to 2020.1.17 since it worked on that version of unity.
     
  5. ishimurax

    ishimurax

    Joined:
    May 7, 2020
    Posts:
    6
    Update: I haven't been able to make it work on this editor version.
    I restored to my physical backup which was for unity version 2019.3.15f1 and upgraded it to 2020.1.17 this time. It is working now.
     
  6. mantassk

    mantassk

    Unity Technologies

    Joined:
    Apr 27, 2017
    Posts:
    9
    Hey, could someone report a bug and attach the case number here or send me a private message? If you could attach a project that would be very helpful in debugging the issue.
     
  7. namadeveloper1

    namadeveloper1

    Joined:
    Mar 27, 2018
    Posts:
    1
    We're a small game studio and we have just experienced this issue with large number of users. This issue happens only on devices Android 9 or newer. Any device using OS older than Android 9 will run the game just fine.

    The reason we missed it in our testing is the issue doesn't happen with APK build, it happens with Android App Bundle (AAB) build only. (We stayed late so we thought testing APK build would just be fine, then we paid for that).

    We're rolling back to Unity 2020.1.17 as suggested above. Hope you guys will find a better solution soon.
     
  8. alexds9

    alexds9

    Joined:
    Feb 9, 2019
    Posts:
    9
    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 working fine.
    I followed @namadeveloper1 advice to downgrade to 2020.1.17f1, had to clean and reinstall packages/plugins.
    Now AAB installed from Google Store is working as expected, no more "libmain.so" error on launch.
     
  9. savantedroid

    savantedroid

    Joined:
    Oct 8, 2015
    Posts:
    8
    Did anybody issue a bug for this?
     
  10. Volcore

    Volcore

    Joined:
    Jan 14, 2020
    Posts:
    14
    Same issue here. Unity 2020.2.1f1. Would rather not downgrade. Any insights?
     
  11. Volcore

    Volcore

    Joined:
    Jan 14, 2020
    Posts:
    14
    nik_d likes this.
  12. nik_d

    nik_d

    Joined:
    Apr 27, 2018
    Posts:
    65
    Reproduced in pure empty project in Unity 2020.2.3f1.
    Reported as (Case 1314472).

    Workaround:
    * Use custom gradle properties template
    * Add to its end:
    android.bundle.enableUncompressedNativeLibs=false

    (It's the only difference between Exported Project and the project located in Temp when building from GUI)
     
    eugene_ivanov and Volcore like this.
  13. mantassk

    mantassk

    Unity Technologies

    Joined:
    Apr 27, 2017
    Posts:
    9
    Hey, the case is being worked on at the moment. Once I will have any updates, I will let you know.
     
  14. SRG-Team

    SRG-Team

    Joined:
    May 15, 2015
    Posts:
    1
    I'm getting the same issue on 2019.4.17f1 trying to run on a Pixel 4a running Android 11 build number RQ1A.210105.002. I've been on this Unity version for a while now, and have tested the game on this phone before, so im leaning towards an issue with an Android update.
     
  15. FlynnMac92

    FlynnMac92

    Joined:
    Aug 24, 2020
    Posts:
    2
    Any update to this?
     
  16. lorenzog45

    lorenzog45

    Joined:
    Sep 20, 2019
    Posts:
    1
    I also ran into this and just built an APK instead of AAB as a quick fix
     
  17. FlynnMac92

    FlynnMac92

    Joined:
    Aug 24, 2020
    Posts:
    2
    Anyone tried 2020.3.0f1 yet?
     
  18. unity_cwGdSCczCn3Frw

    unity_cwGdSCczCn3Frw

    Joined:
    Feb 22, 2021
    Posts:
    4
    This is still an issue with 2020.3.0f1 (also the gradle.properties workaround is not working in my Flutter project either).

    EDIT:

    Actually adding
    android:extractNativeLibs="true"
    to the <application> element in AndroidManifest.xml as a temporary workaround does work with 2020.3.0f1. This might be specific to my version of Gradle (per <application> | Android Developers, this is set to false by default in Android Gradle plugin 3.6.0).

    This isn't a long-term solution as Unity should be able to handle loading native libraries without extracting to the filesystem first.

    I also confirm this is still present in 2021.1.0b11
     
    Last edited: Mar 15, 2021
    vcamargo9 likes this.
  19. vl4dimir

    vl4dimir

    Joined:
    Jun 28, 2012
    Posts:
    18
    I've also submitted a bug report, attaching a minimal project demonstrating the bug. The ID on FogBugz is 1321977. None of the workarounds worked for me BTW (Unity 2020.2.7f1). A complete showstopper...
     
  20. LarsNonne

    LarsNonne

    Joined:
    Jun 30, 2016
    Posts:
    5
    Hi,
    would you mind elaborating more on your settings? For me this workaround still doesn't work.

    I'm using Unity 2020.3 with Android Api 30 (also tested 28), IL2CPP and Google PAD.
    Maybe it is this specific combination, who knows.
    I tried your manifest addition and the gradleTemplate addition, but nothing seems to work.

    Any help to get the app running on android again is much appreciated.
     
  21. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    2,606
  22. unity_cwGdSCczCn3Frw

    unity_cwGdSCczCn3Frw

    Joined:
    Feb 22, 2021
    Posts:
    4
    Can you post your AndroidManifest.xml, build.gradle and gradle.properties? I'm running this via a Flutter app so it will be easier for me to check your files against mine to see if there's any version mismatches.
     
  23. LarsNonne

    LarsNonne

    Joined:
    Jun 30, 2016
    Posts:
    5
    Sorry, I'm not sure how to get the final versions of those files, since building as project with the Google build-pipline inside Unity does not support exporting a project, right? In the .aab I was only able to find the Manifest, but not the gradle files (which makes sense, since that step is already done).
    I never really had to change any of those, so I simply used the template-overrides in the Unity Prefs. Is that correct?

    Here's the Manifest:
    Code (JavaScript):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    3.     package=[censored]
    4.     platformBuildVersionCode="30"
    5.     platformBuildVersionName="11"
    6.     android:compileSdkVersion="30"
    7.     android:compileSdkVersionCodename="11"
    8.     android:installLocation="preferExternal"
    9.     android:versionCode="1"
    10.     android:versionName="0.1" >
    11.  
    12.     <uses-sdk
    13.         android:minSdkVersion="25"
    14.         android:targetSdkVersion="30" />
    15.  
    16.     <supports-screens
    17.         android:anyDensity="true"
    18.         android:largeScreens="true"
    19.         android:normalScreens="true"
    20.         android:smallScreens="true"
    21.         android:xlargeScreens="true" />
    22.  
    23.     <uses-feature android:glEsVersion="0x00030000" />
    24.     <uses-feature
    25.         android:name="android.hardware.vulkan.version"
    26.         android:required="false" />
    27.  
    28.     <uses-permission android:name="android.permission.INTERNET" />
    29.     <uses-permission android:name="android.permission.VIBRATE" />
    30.     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    31.  
    32.     <uses-feature
    33.         android:name="android.hardware.location.gps"
    34.         android:required="false" />
    35.     <uses-feature
    36.         android:name="android.hardware.location"
    37.         android:required="false" />
    38.     <uses-feature
    39.         android:name="android.hardware.touchscreen"
    40.         android:required="false" />
    41.     <uses-feature
    42.         android:name="android.hardware.touchscreen.multitouch"
    43.         android:required="false" />
    44.     <uses-feature
    45.         android:name="android.hardware.touchscreen.multitouch.distinct"
    46.         android:required="false" />
    47.  
    48.     <uses-permission android:name="com.android.vending.BILLING" />
    49.     <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    50.  
    51.     <application
    52.         android:extractNativeLibs="true"
    53.         android:icon="@mipmap/app_icon"
    54.         android:label="@string/app_name" >
    55.         <activity
    56.             android:name="com.unity3d.player.UnityPlayerActivity"
    57.             android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density"
    58.             android:hardwareAccelerated="false"
    59.             android:launchMode="singleTask"
    60.             android:screenOrientation="fullSensor"
    61.             android:theme="@style/UnityThemeSelector" >
    62.             <intent-filter>
    63.                 <action android:name="android.intent.action.MAIN" />
    64.  
    65.                 <category android:name="android.intent.category.LAUNCHER" />
    66.             </intent-filter>
    67.  
    68.             <meta-data
    69.                 android:name="unityplayer.UnityActivity"
    70.                 android:value="true" />
    71.         </activity>
    72.  
    73.         <meta-data
    74.             android:name="unity.splash-mode"
    75.             android:value="0" />
    76.         <meta-data
    77.             android:name="unity.splash-enable"
    78.             android:value="True" />
    79.         <meta-data
    80.             android:name="unity.build-id"
    81.             android:value=[censored] />
    82.         <meta-data
    83.             android:name="com.google.android.play.billingclient.version"
    84.             android:value="3.0.1" />
    85.  
    86.         <activity
    87.             android:name="com.android.billingclient.api.ProxyBillingActivity"
    88.             android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
    89.             android:exported="false"
    90.             android:theme="@android:style/Theme.Translucent.NoTitleBar" />
    91.         <activity
    92.             android:name="com.google.android.play.core.missingsplits.PlayCoreMissingSplitsActivity"
    93.             android:enabled="false"
    94.             android:exported="false"
    95.             android:launchMode="singleInstance"
    96.             android:process=":playcore_missing_splits_activity"
    97.             android:stateNotNeeded="true" />
    98.         <activity
    99.             android:name="com.google.android.play.core.common.PlayCoreDialogWrapperActivity"
    100.             android:enabled="false"
    101.             android:exported="false"
    102.             android:stateNotNeeded="true"
    103.             android:theme="@style/Theme.PlayCore.Transparent" />
    104.  
    105.         <service
    106.             android:name="com.google.android.play.core.assetpacks.AssetPackExtractionService"
    107.             android:enabled="false"
    108.             android:exported="true" />
    109.     </application>
    110.  
    111. </manifest>
    When exporting the project with the standard export setting from build settings these files are generated:

    build.gradle
    Code (JavaScript):
    1. // GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
    2.  
    3. allprojects {
    4.     buildscript {
    5.         repositories {
    6.             google()
    7.             jcenter()
    8.         }
    9.  
    10.         dependencies {
    11.             classpath 'com.android.tools.build:gradle:3.6.0'
    12.            
    13.         }
    14.     }
    15.  
    16.     repositories {
    17.         google()
    18.         jcenter()
    19.         flatDir {
    20.             dirs "${project(':unityLibrary').projectDir}/libs"
    21.         }
    22.     }
    23. }
    24.  
    25. task clean(type: Delete) {
    26.     delete rootProject.buildDir
    27. }
    gradle.properties
    Code (JavaScript):
    1. org.gradle.jvmargs=-Xmx4096M
    2. org.gradle.parallel=true
    3. android.enableR8=false
    4. unityStreamingAssets=.unity3d, google-services-desktop.json
    5. android.bundle.enableUncompressedNativeLibs=false
     
    Last edited: Mar 17, 2021
    vcamargo9 likes this.
  24. unity_cwGdSCczCn3Frw

    unity_cwGdSCczCn3Frw

    Joined:
    Feb 22, 2021
    Posts:
    4
    OK, the only thing I can suggest is changing

    classpath 'com.android.tools.build:gradle:3.6.0'
    to
    classpath 'com.android.tools.build:gradle:4.1.2'

    and removing enableUncompressedNativeLibs from gradle.properties. Otherwise, that looks consistent with mine, so if it doesn't work for you, maybe the Flutter build scripts are doing something with Gradle that happens to fix the issue.

    (I'm new to Unity but I understand you can just delete the "GENERATED BY UNITY." comments, edit the files and re-export to use the modified properties).

    Also maybe try changing compileSdkVersion to 29, changing gradle-wrapper.properties to use
    gradle-6.5-all.zip and Unity 2021.1.0b11.2079. That will be as consistent as possible with my setup but I doubt it's going to make a difference, fairly sure the issue is with Unity/Android Gradle plugin, nothing else.
     
  25. LarsNonne

    LarsNonne

    Joined:
    Jun 30, 2016
    Posts:
    5
    I tried exporting the project and building in android studio with the updated gradle. The app was starting again, but unfortunately that breaks the Google Play Services (did I miss something here?). Upgrading Gradle inside Unity is, as I understand it, a bigger problem. Each Unity Version comes with a Gradle Version that is tested with that specific Unity Version. Updating this can potentially break a lot of things, especially when upgrading to another major version.
    Might be a last restort to test for me though...

    Usually I would just wait for the fix to be pushed, but I need a working build (for demonstration purposes) in 5 days, so there's that.

    Thanks a lot for your help!
    At least now I understand more of where the problem comes from and can try to fix it somehow.

    [Update]
    Updating Gradle to the newest version did not create any build errors for me, but didn't fix the issue either. So there must be some other difference.
     
    Last edited: Mar 17, 2021
  26. genoompjes2

    genoompjes2

    Joined:
    Mar 23, 2021
    Posts:
    1
    Got the same error on my emulators. But when i run this on a physical device (samsung s10 SM-G73F) it works fine. I am new to this and already tried for 2 weeks to get this working.
     
  27. domonyiv

    domonyiv

    Joined:
    Oct 1, 2016
    Posts:
    17
  28. Binouze

    Binouze

    Joined:
    Mar 2, 2017
    Posts:
    93
    domonyiv likes this.
  29. domonyiv

    domonyiv

    Joined:
    Oct 1, 2016
    Posts:
    17
  30. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    2,606
    I don't think so, but can't say for sure.
     
  31. karyll

    karyll

    Joined:
    Apr 4, 2017
    Posts:
    38
  32. Binouze

    Binouze

    Joined:
    Mar 2, 2017
    Posts:
    93
  33. karyll

    karyll

    Joined:
    Apr 4, 2017
    Posts:
    38
    excuse my noobness , but in Unity Hub I only see 2020.3.2f1. Does it mean that 2020.3.3f1 has not been rolled out yet?
     
    eelir_g likes this.
  34. vl4dimir

    vl4dimir

    Joined:
    Jun 28, 2012
    Posts:
    18
    This is still happening for me with Unity 2021.1.1f1. I've made my small repo demonstrating the bug available on Github, see this other thread for details.
     
  35. karyll

    karyll

    Joined:
    Apr 4, 2017
    Posts:
    38
    I think you need to wait for 2021.1.2f1 to be rolled out.
     
  36. sharonj731

    sharonj731

    Joined:
    Jun 10, 2018
    Posts:
    5

    I'm using 2020.3.2f1 and this edit saves me for the time-being. I dreaded upgrading to 2020 but got forced into trying it. Other breaks to research, but this one at least has me up and running again. I'm grateful!
     
  37. addavies

    addavies

    Joined:
    May 18, 2018
    Posts:
    3
    I was getting this same error using the uaal github example and none of these fixes seemed to work. I even upgraded to Unity 2020.3.3f1 and get this error when pressing the Show Unity button. Credit to benoit-dumas for this fix that worked for me.

    Failure to initialize!
    Your hardware does not support this application.
    Failed to load 'libmain.so'

    Adding this to my app level build.gradle file solved the issue

    defaultConfig {
    ndk {
    abiFilters 'armeabi-v7a', 'x86'
    }
    }
     
unityunity