Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by millerlm012 · Feb 08, 2021 at 10:29 PM · adsadmob

How to test a Unity app with Google AdMob on a test device?

I have AdMob displaying the demo images for banner ads within the Unity Game Engine Editor fine, but when I side load the app onto my phone nothing is being displayed... How do I test ads on my test device? I have set up the device as a test device in AdMob's UI, and I've tried using both my real ad unit id's and the test ones with no success. My account has been verified and I've waited up to a couple of days to see if it just needs to time as I've read that was the issue for some other people. I've seen some people say that I need to set up a payment method, but that's greyed out for me saying that I don't need to set one up until my "earnings threshold has been reached." I will have code and log files below for additional assistance with troubleshooting. Thanks! (NOTE: I have removed my actual adUnitId's for the sake of privacy)

Code for Banner Ad's Below: C# in Unity

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

public class Ads : MonoBehaviour

{ private BannerView bannerView;

 // Start is called before the first frame update
 void Start()
 {
   // Initializes the GoogleMobileAds (GoogleAdMob) SDK
   MobileAds.Initialize(initStatus => { });

   this.RequestBanner();
 }

 private void RequestBanner()
 {
     // Clean up banner ad before creating a new one.
     if (this.bannerView != null)
     {
         this.bannerView.Destroy();
     }

     // !! below ad unit IDs are TEST ids -> will need to change to active ID's
     #if UNITY_ANDROID
         string adUnitId = "adUnitId";
     #elif UNITY_IPHONE
         string adUnitId = "adUnitId";
     #else
         string adUnitId = "unexpected_platform";
     #endif

     // creating custom sized banner using adaptive banner method -> works the best so far
     AdSize adaptiveSize = AdSize.GetCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(AdSize.FullWidth);
     this.bannerView = new BannerView(adUnitId, adaptiveSize, AdPosition.Bottom);

     // Create a 320x50 banner at the bottom of the screen.
     // this.bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);

     // Loading the ad to the screen
     // Create an empty ad request.
     AdRequest request = new AdRequest.Builder().Build();

     // Register ad events
     this.bannerView.OnAdLoaded += this.HandleAdLoaded;
     this.bannerView.OnAdFailedToLoad += this.HandleAdFailedToLoad;
     this.bannerView.OnAdOpening += this.HandleAdOpened;
     this.bannerView.OnAdClosed += this.HandleAdClosed;
     this.bannerView.OnAdLeavingApplication += this.HandleAdLeftApplication;

     // Load the banner with the request.
     this.bannerView.LoadAd(request);
 }

 // region Banner callback handlers
 public void HandleAdLoaded(object sender, EventArgs args)
 {
     MonoBehaviour.print("HandleAdLoaded event received");
     MonoBehaviour.print(String.Format("Ad Height: {0}, width: {1}",
         this.bannerView.GetHeightInPixels(),
         this.bannerView.GetWidthInPixels()));
 }

 public void HandleAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
 {
     MonoBehaviour.print("HandleFailedToReceiveAd event received with message: " + args.Message);
 }

 public void HandleAdOpened(object sender, EventArgs args)
 {
     MonoBehaviour.print("HandleAdOpened event received");
 }

 public void HandleAdClosed(object sender, EventArgs args)
 {
     MonoBehaviour.print("HandleAdClosed event received");
 }

 public void HandleAdLeftApplication(object sender, EventArgs args)
 {
     MonoBehaviour.print("HandleAdLeftApplication event received");
 }

} ​​​​​​

Log from running app on phone:

02-08 08:37:05.021 25320 25343 E Unity : AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.ads.initialization.OnInitializationCompleteListener 02-08 08:37:05.021 25320 25343 E Unity : java.lang.ClassNotFoundException: com.google.android.gms.ads.initialization.OnInitializationCompleteListener 02-08 08:37:05.021 25320 25343 E Unity : at java.lang.Class.classForName(Native Method) 02-08 08:37:05.021 25320 25343 E Unity : at java.lang.Class.forName(Class.java:454) 02-08 08:37:05.021 25320 25343 E Unity : at com.unity3d.player.UnityPlayer.nativeRender(Native Method) 02-08 08:37:05.021 25320 25343 E Unity : at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0) 02-08 08:37:05.021 25320 25343 E Unity : at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95) 02-08 08:37:05.021 25320 25343 E Unity : at android.os.Handler.dispatchMessage(Handler.java:102) 02-08 08:37:05.021 25320 25343 E Unity : at android.os.Looper.loop(Looper.java:223) 02-08 08:37:05.021 25320 25343 E Unity : at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20) 02-08 08:37:05.021 25320 25343 E Unity : Caused by: java.lang.ClassNotFoundException: com.google.android.gms.ads.initialization.OnInitializationCompleteListener 02-08 08:37:05.021 25320 25343 E Unity : ... 8 more 02-08 08:37:05.021 25320 25343 E Unity : at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in :0 02-08 08:37:05.021 25320 25343 E Unity : at UnityEngine.AndroidJNISafe.FindClass (System.String name) [0x00000] in <000000000000000000000 02-08 08:37:51.566 25320 25343 E Unity : NullReferenceException: Object reference not set to an instance of an object. 02-08 08:37:51.566 25320 25343 E Unity : at GoogleMobileAds.Api.MobileAds.Initialize (System.Action`1[T] initCompleteAction) [0x00000] in :0 02-08 08:37:51.566 25320 25343 E Unity : at Ads.Start () [0x00000] in :0 02-08 08:37:51.566 25320 25343 E Unity : 02-08 08:37:51.566 25320 25343 E Unity : (Filename: currently not available on il2cpp Line: -1) 02-08 08:37:51.566 25320 25343 E Unity : 02-08 08:38:17.531 25320 25343 E Unity : NullReferenceException: Object reference not set to an instance of an object. 02-08 08:38:17.531 25320 25343 E Unity : at GoogleMobileAds.Api.MobileAds.Initialize (System.Action`1[T] initCompleteAction) [0x00000] in :0 02-08 08:38:17.531 25320 25343 E Unity : at Ads.Start () [0x00000] in :0 02-08 08:38:17.531 25320 25343 E Unity : 02-08 08:38:17.531 25320 25343 E Unity : (Filename: currently not available on il2cpp Line: -1) 02-08 08:38:17.531 25320 25343 E Unity :

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

157 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Admob Errors 1 Answer

Need help/guide on how to show AdMob interstitial ads 0 Answers

How to create a remove ads in app purchase for unity android game? 1 Answer

Unity admob ads null reference 0 Answers

Google AdMob plugin duplicate ,AdMob Duplicate class SOLVED 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges