Yesterday I update Unity to 2019.3.* and I have the same issue.
Before update (version 2019.2.*) the same code (even without tools:replace) worked perfectly.
Something must change beetwen ths version.
For now - this is ugly hack, not fix - you can change Unity source manifest file located in: [UnityInstalation]\Editor\Data\PlaybackEngines\AndroidPlayer\
The supported screens element was moved to the launcher manifest. There is no official way to modify this manifest in Unity editor. You will have to export your project, then modify the launcher manifest the way you want and finally build the project using Android Studio.
@JuliusM Can you guys please remove the supported screens section out of the launcher manifest, or give the user the option via the Unity Editor to enable/disable this.
I found an example using the OnPostGenerateGradleAndroidProject() callback to edit the manifest during the build. But this is called before the gradleOut\launcher\src\main\ manifest is merged with the gradleOut\unityLibrary\src\main\ manifest, so the conflict will still happen even if I edit the unityLibrary version.
@JuliusM can you suggest a workaround to this problem? Can we edit the merged manifest in code somehow?
The option to overwrite templates have been added to Unity 2020.1.0b2 and 2019.3.7f1. Also an option to overwrite gradle properties template was added to Unity 2018.4.21f1.
@JuliusM
âThe option to overwrite templates have been added to Unity 2020.1.0b2 and 2019.3.7f1. Also an option to overwrite gradle properties template was added to Unity 2018.4.21f1.â
Itâs doesnât work for me.
Custom Main Manifest (Assets/Plugins/Android/AndroidManifest.xml):
Unity generated this (Temp/gradleOut/launcher/src/main/AndroidManifest.xml):
<?xml version="1.0" encoding="utf-8"?>
<!-- GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.levius.afterlifeidle" xmlns:tools="http://schemas.android.com/tools" android:installLocation="preferExternal">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
<application android:label="@string/app_name" android:icon="@mipmap/app_icon" />
</manifest>
And result:
AndroidManifest.xml:4:21-48 Error:
Attribute supports-screens@smallScreens value=(true) from AndroidManifest.xml:4:21-48
is also present at [:unityLibrary] AndroidManifest.xml:21:9-37 value=(false).
Suggestion: add âtools:replace=âandroid:smallScreensââ to element at AndroidManifest.xml:4:3-163 to override.
In old version all compiling fine. In 2019.3 I canât build android version. Maybe I donât understand how it works?
Assets/Plugins/Android/AndroidManifest.xml overwrites the main manifest, so the launcher manifest does not get overwritten. Since supports-screens is already added to a default launcher manifest, you get this error. You will have to overwrite launcher manifest as well.
I managed to work around this limitation by changing the AndroidManifest.xml from the Unity installation (Iâm using 2018.4.19f1). In my case the file is located at: D:\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Apk ⌠itâs a dirty hack but could be useful to skip this limitation âŚ
Since Unity 2019.3.7f1 there is an option in the player settings â publishing settings allowing to provide a custom launcher manifest. Enable the checkbox and a launcher manifest will be created in your projectâs Plugins/Android directory, then you can modify the template. See my post above #12
I managed to fix this issue by creating my own Manifest.xml in the relative path Assets\Plugins\Android\Manifest.xml putting my manifest there Unity use it instead of the default one (in my installation C:*Unity\Editor\Data\PlaybackEngines\AndroidPlayer)*