Unity3D game crashes during loading screen on Android 4.0.1 (Android ICS)

One common issue people having on the Unity3D Android Forums  and keep asking over and over is a certain crash issue, which happens during the start of the Unity3D game app on Android 4.0.1 (Ice Cream Sandwich).

This is a very common error, which happens when old apps are being ported to Android 4.0.1 (ICS). With Android 4.0.1, new configOrientation options were added, due to the new design changes in the Android Operating System.

<activity
    android:configChanges=["mcc", "mnc", "locale",
        "touchscreen", "keyboard", "keyboardHidden",
        "navigation", "screenLayout", "fontScale", "uiMode",
        "orientation", "screenSize", "smallestScreenSize"]

The last 3 options – orientation, screenSize and smallestScreenSize – where added with Android 4.0 ICS. Unity3D 3.5 added support for those and since then Unity3D needs to be built against Android API 13 (ICS).
When these are missing in the AndroidManifest.xml’s activity declaration, then Unity3D won’t get notified when this events occurs and can’t do the necessary steps to react on it.

One of the reason this events were added was because the new Android 4.0 devices have no physical buttons and the buttons appear as part of the display which get displayed or hidden depending on the current applications context.

orientation The screen orientation has changed — the user has rotated the device.
Note: If your application targets API level 13 or higher (as declared by the minSdkVersion and targetSdkVersion attributes), then you should also declare the “screenSize” configuration, because it also changes when a device switches between portrait and landscape orientations.
screenSize The current available screen size has changed. This represents a change in the currently available size, relative to the current aspect ratio, so will change when the user switches between landscape and portrait. However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).
Added in API level 13.
smallestScreenSize The physical screen size has changed. This represents a change in size regardless of orientation, so will only change when the actual physical screen size has changed such as switching to an external display. A change to this configuration corresponds to a change in the smallestWidth configuration. However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).
Added in API level 13

By default, Unity3D uses it’s own AndroidManifest.xml file, which can be found at C:\Program Files (x86)\Unity\Editor\Data\PlaybackEngines\androiddevelopmentplayer\AndroidManifest.xml on Windows Vista and Windows 7 or in C:\Program Files\Unity\Editor\Data\PlaybackEngines\androiddevelopmentplayer\AndroidManifest.xml on older Windows versions.

But when the users place their own AndroidManifest.xml file in the Unity3D project’s Assets/Plugins/Android folder, Unity3D include this file into the final APK. Usually people take a copy of this file, place it in the Assets/Plugins/Android and modify it for their needs. There are also some Eclipse integration example projects, which makes it easier creating an Eclipse project which can be later included into Unity3d build process (i.e. exporting the Eclipse project as Android.jar and placing it in Assets/Plugins/Android folder) and they use an outdated AndroidManifest.xml file too.

In order to fix that, the AndroidManifest.xml file needs to be updated and the missing configChanges and change them to

android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">

This is what the default Unity3D AndroidManifest.xml file from version 3.5 does. A complete example AndroidManifest.xml can be found below.

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.unity3d.player"
	android:installLocation="preferExternal"
    android:versionCode="1"
    android:versionName="1.0">
    <supports-screens
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true"
        android:anyDensity="true"/>

    <application
		android:icon="@drawable/app_icon"
        android:label="@string/app_name"
        android:debuggable="true">
        <activity android:name="com.unity3d.player.UnityPlayerProxyActivity"
                  android:label="@string/app_name"
                  android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.unity3d.player.UnityPlayerActivity"
                  android:label="@string/app_name"
                  android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
        </activity>
        <activity android:name="com.unity3d.player.UnityPlayerNativeActivity"
                  android:label="@string/app_name"
                  android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
            <meta-data android:name="android.app.lib_name" android:value="unity" />
            <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
        </activity>
        <activity android:name="com.unity3d.player.VideoPlayer"
                  android:label="@string/app_name"
                  android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
        </activity>
    </application>
</manifest>

If that doesn’t help solving the problem, disabling auto screen-rotation often helps, i.e. by adding

android:screenOrientation="landscape"

to the tag and/or setting it in Unity3D Android player settings

4 Comments on “Unity3D game crashes during loading screen on Android 4.0.1 (Android ICS)

  1. I’m a 3d 2d character artist hoping to aply for the job hit me up at my email:void013.comuf@gmail.com
  2. Though it wasn’t exactly my issue, my problem WAS in the manifest file. So thanks for pointing in that direction, and thanks especially for adding a stock manifest for comparison.