Search Unity

Proper method to modify AndroidManifest.xml for small additions

Discussion in 'Android' started by 39thstreet, Jan 22, 2018.

  1. 39thstreet

    39thstreet

    Joined:
    Jan 30, 2012
    Posts:
    104
    I have read the docs on the Android Manifest here:
    https://docs.unity3d.com/Manual/android-manifest.html

    I think I understand the concept. I want to add a single parameter to the activity and otherwise leave the generated manifest alone. (Specifically I want to add android:maxAspectRatio="1.86" to the activity tag). How do I do this?

    I understand the manifests will be merged, but what does that mean? Do I have to copy the entire default manifest from the unity directory and make my one addition? Is it possible to just include a fragment of XML to be merged?

    So far every test I have done just results in merge errors.

    Google is really failing me, feel like this would be a common question. Would appreciate any help.
     
    leni8ec and Mccbbi like this.
  2. Mccbbi

    Mccbbi

    Joined:
    Feb 8, 2015
    Posts:
    12
    +1
    I also tried to do that many times and every time I find bad temporary solutions. This time i modified manifest in Play Games plugin folder..;/ but if (when?) this plugin is someday updated I will have to search for bugs again(
     
  3. samizzo

    samizzo

    Joined:
    Sep 7, 2011
    Posts:
    487
    It's been a while since I had to do this but I'm pretty sure you should be able to just take the default Unity Android manifest, remove everything you don't need, add what you do need, and stick it in Assets/Plugins/Android/AndroidManifest.xml and Unity should merge it. It will have to be a full XML, not a fragment.

    Sam
     
    Mccbbi likes this.
  4. Mccbbi

    Mccbbi

    Joined:
    Feb 8, 2015
    Posts:
    12
    You are right, I tried that, but unity overwrites some of its default settings (for final manifest) with my manifest in this folder and always caise troubles. I only want to add one single parameter and leave all other parameters default (which unity generates). It seems like i dont understand something impoetant about all that process:/
     
    AndreaMar likes this.
  5. samizzo

    samizzo

    Joined:
    Sep 7, 2011
    Posts:
    487
    Hm I guess there is a bug or maybe your situation is just not possible for the Unity manifest merger to handle (it uses a google tool to merge manifests and then also makes some extra changes itself). You might have to export to an Android Studio project and make the changes in there which is a bit of a pain.

    Sam
     
  6. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    835
    First of all, which Unity version do you use? If it's not a very old version, there is an option in Player Settings in Resolution and Presentation to select max aspect ratio. You can also use this API https://docs.unity3d.com/ScriptReference/PlayerSettings.Android-maxAspectRatio.html
    If you use a very old Unity version, then copying the android manifest from the Unity install directory and adding the single line should work.
     
    samizzo likes this.