Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
Hello World v.2

Senior Member
Registered:
Posts: 238
Reply with quote  #1 
Hello guys

Im trying to get admob running in my new unity android game but even after whatching a lot of youtube tutorials and online guides about this, i still would crash the game right on the start. (it only crashes when i start on the phone)


This is my code, i attatched it to the main camera so it will start right in the beginning and show the ad...
I already tried the admob demo script wich works good :/

Hope you can find the bad spot:




using UnityEngine;
using System.Collections;
using GoogleMobileAds.Api;


public class ADMOB_SCRIPT : MonoBehaviour {

    // Use this for initialization
    void Start () {
        RequestBanner ();
    }
    
    // Update is called once per frame
    void Update () {
    
    }

    private void RequestBanner()
    {
        #if UNITY_ANDROID
        string adUnitId = "ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxxxx";
        #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 bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);
        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder ()
            .AddTestDevice (xxxxxxxxxxxxxxx")
            .Build();
        // Load the banner with the request.
        bannerView.LoadAd(request);
    }

}

0
Hello World v.2

Senior Member
Registered:
Posts: 238
Reply with quote  #2 
I think its maybe more about my AndroidManifest.xml file, can someone post a example AndroidManifest.xml file for Admob ?
0
Crichton333

Avatar / Picture

Senior Member
Registered:
Posts: 273
Reply with quote  #3 
When you put in the google project folder under the Plugins in Unity doesnt in come with its own AndroidManifest.xml that just gets merged when building ?

I also had the same problem, Admob crashed the game when testing on the phone but never managed to fix it.

__________________

"Smoke me a kipper i'll be back for breakfast." -- iOS: Nebula Virtual Reality

0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.