Merging Android Manifest Files

So you’ve purchased a couple of Android Unity plugins and want to use them both within your game, however they both come with their own AndroidManifest.xml file so you need to combine them somehow. Hopefully the next few tips will help you out.

The first thing to find out is whether the plugin has to set up it’s own activity as the main launcher activity. For example, all my plugins don’t have to be the main launcher activity, however my facebook(social) plugin loses SSO capability if not set up as the main launcher activity. The line in the manifest file that sets this up will look something like this:

<activity android:name="com.platoevolved.socialpluginunity.SocialPluginUnityActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="portrait">
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />

Also note that at least one of the plugins will need to set itself up as the main launcher activity otherwise the plugins will not be able to respond to user clicks (but will appear to work in all other ways).

So once you have decided which plugin gets the main launcher activity, you now need to merge the important information from the other manifest file. So for example if the other manifest file has extra activities,services, meta-data lines, uses-permissions etc, you should merge these in. Make note whether these should appear before or after the /application tag.

For example here are the important lines from my Admob manifest that should appear just before the tag:

<activity android:name="" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<meta-data android:name="admob_pub_id" android:value="Enter AdMob Publisher ID here"/>
<meta-data android:name="adposition_x" android:value="right"/>
<meta-data android:name="adposition_y" android:value="top"/>
<meta-data android:name="start_hidden" android:value="false"/>

And here are the lines that should appear just after the /application tag:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Note that for my AdMob plugin, if it is not the main launcher activity you will now need to call StartAds() somewhere in your code so that the plugin can get itself initialised.

For an example of three of my plugin manifests getting merged, see here.

For an example of the Admob and InAppBilling plugins merged see here.

Leave a Reply

Your email address will not be published. Required fields are marked *