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