How can I build a manifest with android:targetSdkVersion="21"?

I need to have targetSdkVersion=“21” in my app. How can I build an APK in unity with this?

You can make a customized AndroidManifest.xml and specify the targetSdkVersion, then save this file in folder ProjectRoot/Assets/Plugins/Android (create the folder if it does not exist). Unity will use this customized manifest file while building/exporting the project.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.company.product" android:versionName="1.0.0.1" android:versionCode="1" android:installLocation="auto">
    <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="21" />
    <uses-permission android:name="android.permission.INTERNET" />
    ...
</manifest>

You may build a Google Android project by clicking on Export button, after checking the Google Android Project option in the Build Settings.

After that, in the generated folder, you will find the android-manifest file which you may be able to modify as you like. Then you may perform an usual build to create an apk file for your project.

Note for 22, if you upgrade your Android SDK to 22, restart Unity and remake your APK it will add targetSdkVersion automatically: