- Home /
How to alter the Android Manifest to use my ad-displaying activity in Unity?
So I successfully compiled an android application that displays an ad: ![Android app with an ad][1]
Now, I want to use this in my android game. To do so, I take the following steps;
- In eclipse, label my project as a library, which makes a jar 
- Replace - public class BannerSample extends Activity {with- public class BannerSample extends UnityPlayerActivity {(and add- import com.unity3d.player.UnityPlayerActivity;)
- Remove - setContentView(R.layout.activity_main);
- 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 
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:
 <?xml version="1.0" encoding="utf-8"?>
 <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">
   <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
   <application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false">
     <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">
       <intent-filter>
         <action android:name="android.intent.action.MAIN" />
         <category android:name="android.intent.category.LAUNCHER" />
       </intent-filter>
       <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
     </activity>
   </application>
   <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" />
   <uses-feature android:glEsVersion="0x00020000" />
 </manifest>
Here is the manifest for my ad-display app:
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
           package="com.google.example.gms.ads.banner"
           android:versionCode="1"
           android:versionName="1.0">
     <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" />
 
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
     <uses-permission android:name="android.permission.INTERNET"/>
     
     <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:allowBackup="true">
         <activity android:name=".BannerSample" android:label="@string/app_name">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
         
         <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
         <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
     </application>
     
 </manifest>
 
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.
If I replace
android:name="com.unity3d.player.UnityPlayerNativeActivity">
with
android:name=".BannerSample">
Unity tells me this when I try to compile: ` Unable to find unity activity in manifest. You need to make sure orientation attribut is set to portrait manually. UnityEditor.HostView:OnGUI()
In addition, as you can see in my app's manifest, I have the following two lines:
     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
If I include the second line anywhere (meta-deta) then Unity fails to build my app everytime, giving me the following error:
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_ 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? [1]: /storage/temp/26194-workingad.pngError building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                