Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Where unity-android-resources\AndroidManifest.xml is came from

Discussion in 'Android' started by choyb, Nov 30, 2017.

  1. choyb

    choyb

    Joined:
    Nov 6, 2015
    Posts:
    1
    hi! i recently upgrade my Unity version to 2017, and try to use gradle build.

    But during Android build i encountered some issues with

    [Temp\StagingArea\AndroidManifest-main.xml:2, \Temp\StagingArea\android-libraries\unity-android-resources\AndroidManifest.xml:1] Main manifest has <uses-sdk android:targetSdkVersion='25'> but library uses targetSdkVersion='26'

    Therefore i found AndroidManifest.xml in \Temp\StagingArea\android-libraries\unity-android-resources\ has some problem.

    so i want to change the file, but i cannot find where it come from. I search all 'AndroidManifest.xml' in my project but i cannot find similiar with it.

    Is there anyone know about this?
     
  2. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    359
    That manifest is likely generated automatically for you during the build time, because you provide resources in the Assets/Plugins/Android/res folder. You have two options to solve this issue.
    1) set target sdk version in Unity editor to 26 (or if you've set it to automatic, make sure your android sdk has api level 26 installed), or if you are providing a custom main manifest, set <uses-sdk android:targetSdkVersion='26'> in it.
    2) You should be seeing a warning "Providing Android resources in Assets/Plugins/Android/res is deprecated, please move your resources to an AAR or an Android Library.". So you might want to do just that, which would also fix this issue :)
     
  3. willmoon

    willmoon

    Joined:
    Jan 17, 2018
    Posts:
    2
    why have to set target sdkversion to 26,Is the unity 2017 depends on it ???
    i have Android resources in Assets/Plugins/Android/res,and don't want to chnage to sdk 26,Is there a good way for me ?
     
  4. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    359
    No, Unity 2017 does not depend on sdk version 26, but to fix this issue, using that target sdk version is a possible solution (that's why I've listed it as one of the options).
    Yes, the second solution which I've mentioned in previous post is what you can do. Create an Android library with those resource files and use the library instead of separate files. While creating an Android library you will have to create an AndroidManifest. Make sure to set min and target sdk versions there to the ones you want. This will solve your issue.
     
    willmoon likes this.
  5. willmoon

    willmoon

    Joined:
    Jan 17, 2018
    Posts:
    2
    ok thank you for the reply!!!
     
  6. EveryoneKnowsItsSlinky

    EveryoneKnowsItsSlinky

    Joined:
    Dec 4, 2015
    Posts:
    1
    As a small side note:
    The 'unity-android-resources' is auto generated by Unity to, effectively, automate JulisM's Option 2.
    However, it does not appear to respect the PlayerSettings->target SDK value and, instead, seems to be hardwired to use 26.

    (On the plus side, it _did_ force me to _finally_ move the 'res' files into my own proper library.)
     
    Yury-Habets likes this.
  7. Go3k

    Go3k

    Joined:
    Oct 21, 2015
    Posts:
    16
    Unity version: Unity 2017.2
    I have the same issue, and for some reason I must use sdkVersion 25, I have set the Target API Level in Player Settings to 25, but I still get this error. Is that means I must use sdk 26 on Unity 2017.2?

    Code (CSharp):
    1. CommandInvokationFailure: Unable to merge android manifests. See the Console for more details.
    2. /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/bin/java -Xmx2048M -Dcom.android.sdkmanager.toolsdir="/Users/xxxx/Dev/adt-bundle/sdk/tools" -Dfile.encoding=UTF8 -jar "/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/sdktools.jar" -
    3.  
    4. stderr[
    5.  
    6. ]
    7. stdout[
    8. Warning: [Temp/StagingArea/AndroidManifest-main.xml:2, Temp/StagingArea/android-libraries/unity-android-resources/AndroidManifest.xml:1] Main manifest has <uses-sdk android:targetSdkVersion='25'> but library uses targetSdkVersion='26'
    9. ]
    10. exit code: 1
    11. UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    12. UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    13. UnityEditor.Android.AndroidSDKTools.RunCommandInternal (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    14. UnityEditor.Android.AndroidSDKTools.RunCommandSafe (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    15. UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions)
    16. AbstractCIBuilder:Build() (at Assets/Editor/CITools/Builder/AbstractCIBuilder.cs:102)
    17. SuperKing.Editor.CITools.CIBuilder:BuildAndroidDebug() (at Assets/Editor/CITools/CIBuilder.cs:31)
    18.  
     
    ZanLeO likes this.
  8. MCommand16

    MCommand16

    Joined:
    Apr 24, 2016
    Posts:
    2
    Did anyone solve the problem ?
     
  9. Go3k

    Go3k

    Joined:
    Oct 21, 2015
    Posts:
    16
    No, seems sdk 26 is a must on Unity 2017.2.
     
  10. lingfengxu

    lingfengxu

    Joined:
    Jul 27, 2016
    Posts:
    1
    zhao5359228 likes this.