Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question AndroidManifest missing from unityLibrary/src/main after Project Export for Gradle Build

Discussion in 'Android' started by widekeys, Mar 28, 2023.

  1. widekeys

    widekeys

    Joined:
    Feb 24, 2023
    Posts:
    1
    The Documentation specifies the existence of AndroidManifest.xml in the gradle project structure for a gradle export from unity: https://docs.unity3d.com/Manual/android-gradle-overview.html#gradle-project-structure
    However, when i import the gradle project into Android Studio, the manifest file is missing in the unityLibrary src-main directory.
    I am using Unity 2021.3 for exporting to Android Studio.

    Has anyone encountered a similar problem?
     
    Metz5 likes this.
  2. UBDev2

    UBDev2

    Joined:
    Mar 29, 2017
    Posts:
    11
    I'm having this exact problem right now, have been up all night trying to work it out. It surely can't be a new thing for tonight though right? I don't think I've updated Unity or anything recently. I'll bookmark this thread
     
  3. UBDev2

    UBDev2

    Joined:
    Mar 29, 2017
    Posts:
    11
    I didn't fix it yet, but I managed to find a workaround - I simply copy and pasted my main app's AndroidManifest there, and added a few lines that I was prompted were needed in it for uploading to Oculus for this file. Hope this helps :)

    Edit: For anyone doing the same, the lines I needed to add were pretty much copied from the AndroidManifest seen in this video at around 13:35 minutes in:

    Good luck :)
     
  4. Metz5

    Metz5

    Joined:
    Mar 22, 2023
    Posts:
    1
    Did you find a solution besides copying AndroidManifest.xml from another project?
     
  5. hblee12294

    hblee12294

    Joined:
    Jul 18, 2020
    Posts:
    1
    Yes, same here. The weired thing is that my previous projects work fine, but my lastest one breaks. After a deep dive, I found the reason is the 'XR Plugin Management' (com.unity.xr.management). The lastest plugin 4.3.3 prevented generating the AndroidManifest.xml. When I modified 'com.unity.xr.management' to 4.2.1 in manifest.json, the xml was generated again. I guess there's something wrong with 'com.unity.xr.management'.
     
    Last edited: Apr 28, 2023
    shiota1 and jaydenchoe like this.
  6. mwalus

    mwalus

    Joined:
    Dec 7, 2017
    Posts:
    25
    Same here. Thank you @hblee12294 for workaround - for me it worked too.

    Changelog of "XR Plugin Management" [4.3.1] mentions: "Clean up AndroidManifest.xml every XR build to prevent conflicts with other configurations". So probably sth went wrong :)

    In my case it started to happened after upgrading Unity from 2022.2.15 to 2022.2.16 and change log there mentions package changes:
    com.unity.xr.management: 4.2.04.3.3
     
    jaydenchoe likes this.
  7. AlexisDelforges

    AlexisDelforges

    Joined:
    Nov 30, 2021
    Posts:
    20
    Same problem here, fixed it with
    com.unity.xr.management: 4.3.3→ 4.2.1
     
    UnitDan likes this.
  8. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    959
    It's the following piece of code:

    Code (CSharp):
    1.  
    2.         public void OnPostprocessBuild(BuildReport report)
    3.         {
    4.             // Always remember to cleanup preloaded assets after build to make sure we don't
    5.             // dirty later builds with assets that may not be needed or are out of date.
    6.             CleanOldSettings();
    7.  
    8.             // This is done to clean up XR-provider-specific manifest entries from Android builds when
    9.             // the incremental build system fails to rebuild the manifest, as there is currently
    10.             // (2023-09-27) no way to mark the manifest as "dirty."
    11.             CleanupAndroidManifest();
    12.         }
    13.  
    This is not a valid piece of code.

    We already have quite a few packages embedded because we need to fix them ourselves, adding this to the list.

    Reported as case IN-40099.

    Edit: This has been confirmed and fixed by Unity, with the fix to be included on the next release of the package. I've toned down this message, it was written after I lost two days of work troubleshooting our broken CI builds due to it.
     
    Last edited: May 9, 2023
  9. waldgeist

    waldgeist

    Joined:
    May 6, 2017
    Posts:
    363
    Thanks for the info. Just fell into the same trap. Glad you already found out what the root cause was. Can only imagine how long it took to find it.
     
    AlkisFortuneFish likes this.
  10. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,739
    it's been weeks and still failing. anyone knows when they fix this with an update?
     
    itsnullptr likes this.
  11. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    959
    The fix is in review, but you shouldn't just sit around and wait, embed the package and comment out the
    CleanupAndroidManifest()
    call, or just downgrade to an older version.
     
  12. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,739
    well, all changes get overwritten, and when i modified the manifest to 4.2.1 it says it can't find the package and fails to load
     
  13. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    959
    Hence why you need to embed it, you can't edit packages in the Library.
    Copy the package from <ProjectDir>/Library/PackageCache/ to <ProjectDir>/Packages/ and your changes will stick fine.
     
    creat327 likes this.
  14. kaushaldave

    kaushaldave

    Joined:
    Oct 9, 2020
    Posts:
    6
    Faced same issue but was able fixed by down grade the com.unity.xr.management version form 4.3.3 to 4.2.1 but it was installed as dependency in Unity LTS 2022.3.1f1 so need to add "com.unity.xr.management": "4.2.1" to manifest.json and also updaded packages-lock.json from "com.unity.xr.management" from 4.3.3 to 4.2.1
     
    TonyHoyle likes this.
  15. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,739
    i wonder when is this planned to be fixed, probably for the release of Apple Vision Pro in 2024... considering the speed bugs are getting fixed lately
     
  16. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    959
  17. dltmdghks714

    dltmdghks714

    Joined:
    Feb 3, 2023
    Posts:
    3
     
  18. mwalus

    mwalus

    Joined:
    Dec 7, 2017
    Posts:
    25
    I think just by modifying entry in manifest.json file.
    However, issue was fixed in [4.4.0]: changelog sais: "AndroidManifest.xml is no longer deleted after each Android build"