Search code examples
javac#androidxmlunity-game-engine

Use custom Manifest file and permission in Unity?


Im currently trying to program a little game for android with Unity3D. Because I want a visible status bar, I modified the AndroidManifest in the Project Folder (C:\Users\Public\Documents\Unity Projects\ProjectName\Temp\StagingArea) like this :

<application android:theme="Theme.Light.NoTitleBar" android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false" android:isGame="true" android:banner="@drawable/app_banner">

But everytime i generate the APK, unity changes the Android Manifest to this :

<application android:theme="@style/UnityThemeSelector" android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false" android:isGame="true" android:banner="@drawable/app_banner">

Unity3D does change my modified Manifests everytime?


Solution

  • You are modifying the wrong AndroidManifest file. That AndroidManifest from <ProjectName>\Temp\StagingArea you are modifying is generated by unity each time you build your project.

    To use a custom AndroidManifest file, you have to put your custom AndroidManifest file at <ProjectName>Assets\Plugins\Android.

    1.Go to <UnityInstallationDirecory>\Editor\Data\PlaybackEngines\AndroidPlayer\Apk, Copy the AndroidManifest.xml file to your <ProjectName>Assets\Plugins\Android

    2.Open the copied Manifest file from <ProjectName>Assets\Plugins\Android and add your manifest.

    In your particular case, add <application android:theme="Theme.Light.NoTitleBar" android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false" android:isGame="true" android:banner="@drawable/app_banner"> to it. Save, Build and Run.

    Unity will now use that AndroidManifest file. If you get crash or any other problem, then Unity does not want you to change that.