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

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 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?

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 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 :slight_smile:

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 ?

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.

1 Like

ok thank you for the reply!!!

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.)

1 Like

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?

CommandInvokationFailure: Unable to merge android manifests. See the Console for more details.
/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" -

stderr[

]
stdout[
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'
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
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)
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)
UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions)
AbstractCIBuilder:Build() (at Assets/Editor/CITools/Builder/AbstractCIBuilder.cs:102)
SuperKing.Editor.CITools.CIBuilder:BuildAndroidDebug() (at Assets/Editor/CITools/CIBuilder.cs:31)
1 Like

Did anyone solve the problem ?

No, seems sdk 26 is a must on Unity 2017.2.

I think I found a proper solution for this issue. I wrote a blog about it. Follow TLDR if you are in a hurry.

Since I’m not an Android expert, please let me know if anything is inaccurate. I’ll correct them.

2 Likes