Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Android 6.0 and up: Build crashes from Google Play until Storage is Cleared

Discussion in 'Android' started by Haze-Games, Aug 22, 2019.

  1. Haze-Games


    Mar 1, 2015
    Hi all,

    Thank you in advance for reading this!

    EDIT: After research, we sloved the issue (solution in a next post below with steps), and we discovered it isn't a 64-bit only related error, but due to user data auto backup on Google Play.

    Here's the general information to start with:
    • I build Android App Bundles
    • Using Unity 2019.1.14f1, IL2CPP, Strip Engine Code disabled, Managed Stripping set to Low
    • Architectures: ARMv7 + x64
    It runs fine without errors on all devices when I use Build & Run.

    The issue: once the AAB is uploaded to Google Play, the game works fine on ARMv7 architectures, but on x64 (Moto G7 Power, Android 9):
    • If a previous version of the game is installed, and I update it, it works fine
    • If I clear data, uninstall the game fully, then reinstall it (to test a fresh install), it crashes instantly on launch, without ever showing the splash screen
    • If I restart the phone, it doesn't solve it
    • The only way to solve it is to Clear Storage data after the fresh install, right before first launch (or after it has crashed). After clearing data, it works fine. Strangely, even if it has been freshly installed with cleared data before uninstall, it "comes from Google Play" with 7Mb of local storage data - isn't that supposed to be empty on a fresh install?

    In addition, the logcat coming from a development build that crashes doesn't say much and stops suddenly - maybe it isn't a crash but a force exit?:

    Code (CSharp):
    1. 08-22 09:12:58.827  2641  2697 I Unity   : SystemInfo CPU = ARM64 FP ASIMD AES, Cores = 8, Memory = 3571mb
    2. 08-22 09:12:58.827  2641  2697 I Unity   : SystemInfo ARM big.LITTLE configuration: 4 big (mask: 0xf0), 4 little (mask: 0xf)
    3. 08-22 09:12:58.827  2641  2697 I Unity   : ApplicationInfo com.hazegames.fractalspacetv version 2.2.2 HD build a5449434-bb24-4e25-af4b-3211b9fb6db8
    4. 08-22 09:12:58.828  2641  2697 I Unity   : Built from '2019.1/staging' branch, Version '2019.1.14f1 (148b5891095a)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'arm64-v8a', Stripping 'Disabled'

    I have searched already over the internet and tried the following:
    • Checked that all AndroidManifest entries use
      instead of the older
    • Added the
      android:allowBackup="false" tools:replace="android:allowBackup
      as it seems to have helped some users with this issue with the game keeping persistent data after uninstalls - no improvement here either
    • Cleared Data of the game before uninstalling, then clearing data of Google Play Store just in case before the fresh install
    • I've seen that for some people, creating a new keystore solved startup crashes on x64. However my game being already live in production, can I create a new keystore and still be able to update the game with that new keystore? I thought that wasn't possible.

    I know that this issue happens on production devices as I already have users on x64 devices that complained about this.

    Additional information:
    1. I'm using the recommended SDK / JDK / NDK that comes installed with Unity
    2. I'm using VoxelBusters' Native Plugins. Doesn't seem to be any issues with it
    3. I have no Unity Packages in the Package Manager (removed all default ones as I don't need them).
    4. I'm using Unity Services, but all are disabled except Cloud Diagnostics, that doesn't seems to report this as a "crash" as I have no entries about this issue.
    5. Interesting to point out that, on an nVidia Shield TV (x64), it works fine on very first install without having to clear any data.
    6. Strangely, Google Play marks my game as "Optimized for Wear OS" on the Play Store page, whereas I have no entries specifying such Wear OS optimization or availability.
    I have found this error on the Play Console, but it's on ARMv7 architecture thus maybe not linked to this, could be linked to a plugin using reflection or something similar?

    Code (CSharp):
    1.   at com.unity3d.player.UnityPlayer.nativeRestartActivityIndicator (Native Method)
    2.   at com.unity3d.player.UnityPlayer.resume (Unknown Source:23)
    3.   at com.unity3d.player.UnityPlayerActivity.onResume (Unknown Source:5)
    4.   at (
    5.   at (
    6.   at (
    7.   at (
    8.   at (
    9.   at (
    10.   at (
    11.   at$H.handleMessage (
    12.   at android.os.Handler.dispatchMessage (
    13.   at android.os.Looper.loop (
    14.   at (
    15.   at java.lang.reflect.Method.invoke (Native Method)
    16.   at$ (
    17.   at (

    I hope I provided all the necessary info - please tell me if you need something more ;)
    Would you have any ideas on how to solve this?

    Last edited: Aug 23, 2019
  2. Tomas1856


    Unity Technologies

    Sep 21, 2012
  3. Haze-Games


    Mar 1, 2015
    OK, great, thanks for the quick reply. Do you mean the error / issue I'm having with force close on x64 Android 9, or the error I provided from the Play Console? As I'm not sure they are actually related yet, I need to investigate more. I'm going to try and reproduce today in an empty project. I'll keep you updated.

    There is a possibility my force close on x64 devices from Google Play until I clear storage is actually not linked to x64 but rather Android 9, regardless of architecture, hard to say for now - since the app has 7Mb of user data after fresh install, it seems like Google Play is providing the device with some default data upon installation with AAB files that is corrupted/incorrect data?

    EDIT: OK I see in the link you mean the error on Play Console, going to check that too and try to find a repro case - as it's not this one that I can repro 100% here, it's the x64 / Android 9 force exit upon fresh install from Google Play

    Will keep you posted,
  4. Haze-Games


    Mar 1, 2015
    I've found something interesting about the Android 9 x64 force exit upon first launch from Google Play with fresh install (which means many users are affected):
    - The game is Install Location doesn't seem to help (tried all)

    However, it seems like it's due to the new feature from Android 8 that backs up user data in Google Drive, even after uninstall.

    By adding both the
    android:allowBackup="false" tools:replace="android:allowBackup
    AND the following steps prevents the user data backup, fixing the crash at start I mentioned:

    1) Create the file:

    2) With the content:
    Code (CSharp):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <full-backup-content>
    3.     <include domain="sharedpref" path="."/>
    4. </full-backup-content>

    3) Add to your AndroidManifest.xml file:
    Code (CSharp):
    1. android:fullBackupContent="@xml/backup_rules"
    inside the
    <application >

    Here's the example of my manifest after this change with highlighted addition inside the brackets [ADD THIS] [/ADD THIS]:
    Code (CSharp):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest xmlns:android=""
    3.     xmlns:tools=""
    4.     package=""
    5.     android:versionName="1.0"
    6.     android:versionCode="1"
    7.     android:allowBackup="false" tools:replace="android:allowBackup">
    8.   <application
    9.         android:icon="@drawable/app_icon"
    10.         android:label="@string/app_name"
    11.         android:hardwareAccelerated="true"
    12.         android:isGame="true"
    13.         [ADD THIS]android:fullBackupContent="@xml/backup_rules"[/ADD THIS]>
    14.     <activity android:name="com.unity3d.player.UnityPlayerActivity"
    15.             android:label="@string/app_name"
    16.             android:clearTaskOnLaunch="false"
    17.             android:screenOrientation="sensorLandscape"
    18.             android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    19.       <meta-data android:name="" android:value="unity" />
    20.       <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
    21.       <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" /> <!-- Important! Without this all the permissions are asked at app startup on Android 6.0 devices. -->
    22.       <intent-filter>
    23.         <action android:name="android.intent.action.MAIN" />
    24.         <category android:name="android.intent.category.LAUNCHER" />
    25.         <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
    26.       </intent-filter>
    27.     </activity>
    28.   </application>
    29.   <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="28" />
    30.   <uses-permission android:name="android.permission.WAKE_LOCK" />
    31.   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    32.   <uses-permission android:name="android.permission.CAMERA" />
    33.   <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
    34.   <uses-feature android:name="" android:required="false" />
    35.   <uses-feature android:name="android.hardware.gamepad" android:required="false"/>
    36.   <uses-feature android:name="" android:required="false"/>
    37. </manifest>

    Thanks to @TextusGames for this idea of fix that I found on this page:

    It seems to fix it for me right now, but I'll come back to you tomorrow when the production build is fully live so I can test in final conditions as this crash only happens from Production build from Google Play.

    I'm now going to check if I can reproduce the other crash I mentioned. Will come back soon!
    Last edited: Aug 22, 2019
  5. Aurimas-Cernius


    Unity Technologies

    Jul 31, 2013
    This crash looks to be related to a known bug with il2cpp builds crashing if data backup of a different apk version is present (and restored after the install). The fix is in the works.
    Haze-Games likes this.
  6. Haze-Games


    Mar 1, 2015
    Yes, you are exactly right! I'll rename this post as it isn't linked to x64 (it's just that my only 64 bit device uses this backup).

    By following the steps in my previous post, it has indeed disabled auto backup and fixed the issue!

    Until an official fix is included and I upgrade, I'll keep this solution. Thanks for the info I'm glad it's on the way!