Question by
iSizz · Jun 09, 2019 at 08:12 AM ·
c#android buildadmobadvertisingblackscreen
Game doesn't work after adding AdMob
Game doesnt start after adding Admob, in the Unity everything forks fine, but when im building game to android and open it - there just a black screen. Here's my script, which i added to empty GameObject.
using System.Collections; using System.Collections.Generic; using UnityEngine; using GoogleMobileAds.Api; using GoogleMobileAds; public class AdBannder : MonoBehaviour { private BannerView bannerView;
public void Start()
{
#if UNITY_ANDROID
string appId = "ca-app-pub-3945473749443628~7640216171";
#elif UNITY_IPHONE
string appId = "ca-app-pub-3940256099942544~1458002511";
#else
string appId = "unexpected_platform";
#endif
// Initialize the Google Mobile Ads SDK.
MobileAds.Initialize(appId);
this.RequestBanner();
}
private void RequestBanner()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-3945473749443628/1192736638";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-3940256099942544/2934735716";
#else
string adUnitId = "unexpected_platform";
#endif
// Create a 320x50 banner at the top of the screen.
bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);
}
}
Comment