1
\$\begingroup\$

I am trying to place ad in my game. i am using unity 5. trying to place admob in my game. in unity editor it displaying dummy message. tried to build the game in android phone after build completed game opened in the phone. in console it displays an error message.Error Message.

i am new to this concept. anybody please help

  1. Downloaded the plugin from admob website
  2. In SDK manager google repository, Google Play Service and Google Play Billing Library was installed
  3. AndroidMainfest.xml file is copied in the asset.

AndroidMainfest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.unity">
<!-- Google Mobile Ads Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Uncomment to add billing for in-app purchase ads -->
<uses-permission android:name="com.android.vending.BILLING" /> 
 <application
android:debuggable="false"
android:icon="@drawable/app_icon"
android:label="@string/app_name" >
   <activity android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:label="@string/app_name" android:launchMode="singleTask" android:screenOrientation="fullSensor" android:name="com.unity3d.player.UnityPlayerNativeActivity">
   <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="true" />
 </activity>
<!-- AdMob Plugin -->
    <activity android:name="com.google.ads.AdActivity"
              android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>

</manifest> 

In main Script i used

using GoogleMobileAds.Api;

public class GameScript : MonoBehaviour {
private BannerView bannerView;

Void Start(){
RequestBanner ();
}

private void RequestBanner()
{
    #if UNITY_ANDROID
    string adUnitId = "unity test id";
    #elif UNITY_IPHONE
    string adUnitId = "INSERT_IOS_BANNER_AD_UNIT_ID_HERE";
    #else
    string adUnitId = "unexpected_platform";
    #endif

    // Create a 320x50 banner at the top of the screen.
    bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Top);
    // Create an empty ad request.
    AdRequest request = new AdRequest.Builder().Build();
    // Load the banner with the request.
    bannerView.LoadAd(request);
}
\$\endgroup\$
1
\$\begingroup\$

I solved the problem. i removed all playstore plugin from my project, then i select Edit -> Reimport all. then I import admob plugin. them in AndroidMainfest.xml i changed "android:value="true" to android:value="false" ".

<activity android:name="com.unity3d.player.UnityPlayerNativeActivity"
android:label="@string/app_name">
<intent-filter>
  <action android:name="android.intent.action.MAIN" />
  <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik"
    android:value="false" />
</activity>
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.