Doubts about target api and AndroidManifest

I dont understand how the target api is chosen.
With old Unity 5 versions like 5.3 there is no target api to choose in the player settings in Editor, so i set the AndroidManifest to the api target version i want.
With Unity 5.6 there is an option called “target api level” where i set the target api but then what i set here wont have any importance as a custom androidmanifest will overwrite any other settings i think?
So my doubt is if what matters is what i have in my manifest and not the editor settings?

This has changed in newer Unity versions. In the latest versions we use the target api specified in the editor and print a warning in the console if the main AndroidManifest has a different target api. Right now I don’t remember in which version this change was made, but it is quite likely that in Unity 5.6 the value in the main AndroidManifest is prioritised.
If you don’t have a specific reason to have this value in the main manifest, I would recommend to remove it from there and set the wanted api level inside the editor.

1 Like

I need the accelerometer and gyroscope enabled in manifest, so if i need a manifest i just dont set the target and min sdk?

yes, that should work. The min and target sdk versions will be taken from the editor and written into the main android manifest.
Note that this only happens for the main android manifest. If you are creating a plugin with it’s own manifest, then min and target sdk versions should be specified there to avoid getting potentially unwanted READ_PHONE_STATE and WRITE_PHONE_STATE permissions added to the manifest.

1 Like