title: How to alter the Android Manifest to use my ad-displaying activity in Unity?
body: <p>So I successfully compiled an android application that displays an ad:
  <img src="https://i.stack.imgur.com/kOUrH.png" alt="Android app with ad">
  Now, I want to use this in my android game that uses the Unity Engine. To do so, I take the following steps;</p>
  
  <ol>
  <li>In eclipse, label my project as a library, which makes a jar</li>
  <li>Replace <code>public class BannerSample extends Activity {</code> with <code>public class BannerSample extends UnityPlayerActivity {</code> (and add <code>import com.unity3d.player.UnityPlayerActivity;</code>)</li>
  <li>Remove <code>setContentView(R.layout.activity_main);</code></li>
  <li>Now back in Unity, I put my newly created bannersample.jar in the Plugins/Android folder, along with the jars my app requires: android-support-v4.jar, classes.jar, google-play-services.jar</li>
  </ol>
  
  <p>Finally, I need to create an Android Manifest in this folder to tell it to use my activity. As a starting point, I go to Temp/StagingArea in my game's directory, where I find the basic Manifest that it generates. Initially it looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.google.example.gms.ads.banner" android:theme="@android:style/Theme.NoTitleBar" android:versionName="1.0" android:versionCode="1" android:installLocation="preferExternal"&gt;
    &lt;supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" /&gt;
    &lt;application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false"&gt;
      &lt;activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="portrait"&gt;
        &lt;intent-filter&gt;
          &lt;action android:name="android.intent.action.MAIN" /&gt;
          &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;
        &lt;meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" /&gt;
      &lt;/activity&gt;
    &lt;/application&gt;
    &lt;uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" /&gt;
    &lt;uses-feature android:glEsVersion="0x00020000" /&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>Here is the manifest for my ad-display app:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
            package="com.google.example.gms.ads.banner"
            android:versionCode="1"
            android:versionName="1.0"&gt;
      &lt;uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" /&gt;
  
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
      &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  
      &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:allowBackup="true"&gt;
          &lt;activity android:name=".BannerSample" android:label="@string/app_name"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          &lt;activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/&gt;
          &lt;meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>However, no matter what I do, no combination of the two files work. And this is where I really need help. How do I merge these two files together? Adding the user permission is no problem, however I cannot get correct activity lines.</p>
  
  <p>If I replace <code>&lt;activity android:name="com.unity3d.player.UnityPlayerNativeActivity"</code> with   <code>&lt;activity android:name=".BannerSample"</code>, Unity tells me this when I try to compile: </p>
  
  <blockquote>
    <p>Unable to find unity activity in manifest. You need to make sure orientation attribut is set to portrait manually.
    UnityEditor.HostView:OnGUI()</p>
  </blockquote>
  
  <p>In addition, as you can see in my app's manifest, I have the following two lines:</p>
  
  <blockquote>
  <pre><code>    &lt;activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/&gt;
      &lt;meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /&gt;
  </code></pre>
  </blockquote>
  
  <p>If I include the second line anywhere (meta-deta) then Unity fails to build my app everytime, giving me the following error:</p>
  
  <blockquote>
    <p>Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
    C:\Users\Owner\Development\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk\build-tools\android-4.4.2\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "C:/Users/Owner/Development/adt-bundle-windows-x86_64-20140321/adt-bundle-windows-x86_64-20140321/sdk/platforms/android-19\android.jar" -F bin/resources.ap_</p>
  </blockquote>
  
  <p>With the exception of the above error, Unity will build the app but it will quit as soon as started. I have tried every combination of the two files in regards with the activities. I have even tried removing some of the jars. Please help, how do I successfully merge these two files? What activities do I include and exclude, and why?</p>