Errors occurred while debugging with ADB logcat. Unity app.

180 views
Skip to first unread message

NIKita

unread,
Jul 19, 2021, 9:41:58 AM7/19/21
to Google Mobile Ads SDK Developers
Hello. There is a problem with google AdMob. Test ads are shown in the editor (There are no errors in the editor), but real ads are not showing on my phone. Then I decided to use USB debugging and found out that the following error occurs:
"NullReferenceException: Object reference not set to an instance of an object. at GoogleMobileAds.Api.MobileAds.Initialize (System.Action`1[T] initCompleteAction) [0x00000] in :0 at Show_ads.Start () [0x00000] in :0"

Here's my script:


  1. using GoogleMobileAds.Api; 
  2. using System.Collections; 
  3. using System; 
  4. using UnityEngine.Scripting; 
  5. [assembly: Preserve]
  6. public class Show_ads : MonoBehaviour
  7.  { 
  8.     //ADS---------------------------- 
  9.     private RewardedAd rewardedAd; 
  10.     private const string RewardedID = "id"; 
  11.     //ADS----------------------------void Start()
  12.       void Start()
  13.       {
  14.         MobileAds.Initialize(initStatus => { });
  15.         LoadRewardedAD();
  16.     }

  17.       private void LoadRewardedAD()
  18.       {
  19.         //load-ad
  20.         rewardedAd = new RewardedAd(RewardedID);
  21.         AdRequest adRequest = new AdRequest.Builder().Build();
  22.         rewardedAd.LoadAd(adRequest);

  23.         rewardedAd.OnUserEarnedReward += HandleUserEarnedReward;
  24.     }
  25.       //Called from another script
  26.       public void ShowRewardedAD()
  27.       {
  28.         if (rewardedAd.IsLoaded())
  29.         {
  30.             rewardedAd.Show();
  31.         }
  32.     }
  33.       public void HandleUserEarnedReward(object sender, Reward args)
  34.       {
  35.         if (Reward_type == 0)
  36.         {
  37.             //gem
  38.         }
  39.         else if (Reward_type == 1)
  40.         {
  41.             //coin

  42.         }
  43.         else if (Reward_type == 2)
  44.         {
  45.             //Respawn

  46.         }
  47.     }

  48.       private IEnumerator WaitAD()
  49.       {
  50.         yield return new WaitForSeconds(3);
  51.         LoadRewardedAD();
  52.       }
  53. }

Who can help?

Mobile Ads SDK Forum Advisor

unread,
Jul 19, 2021, 11:03:32 AM7/19/21
to seim...@gmail.com, google-adm...@googlegroups.com
Hi Nikita,

Thank you for reaching out to us. In looking over your concern, the fact that you are getting no live ads during your development makes sense. As ads are only served when you have developed the app and deployed it to the store, along with it being recognized. At the same time we strongly advise against testing with live ads as it is possible for you to get flagged for invalid clicks and things like that. Always best to use the test ads, especially during development.

Regards,

Google Logo
William Pescherine
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2JBpDU:ref

NIKita

unread,
Jul 20, 2021, 3:49:39 AM7/20/21
to Google Mobile Ads SDK Developers
The game is already in the Google Play Market, but all the ads are not showing jealously. How to fix this error?
"NullReferenceException: Object reference not set to an instance of an object. at GoogleMobileAds.Api.MobileAds.Initialize (System.Action`1[T] initCompleteAction) [0x00000] in :0 at Show_ads.Start () [0x00000] in :0"?

понедельник, 19 июля 2021 г. в 18:03:32 UTC+3, mobileadssdk:

NIKita

unread,
Jul 20, 2021, 9:38:40 AM7/20/21
to Google Mobile Ads SDK Developers
https://github.com/googleads/googleads-mobile-unity/issues/854#issuecomment-482817348 - Here the problem was solved by reducing the level of stripping in the Unity editor or by adding this part of the code: "using UnityEngine.Scripting;
[assembly: Preserve] " to script " GoogleMobileAdsClientFactory.cs ", but this topic was opened in 2019. There is currently no script" GoogleMobileAdsClientFactory.cs "in SDK AdMob and you cannot lower the level of stripping in" unit ". What should I do in Please help me, I have not been able to find a solution for a month.

понедельник, 19 июля 2021 г. в 18:03:32 UTC+3, mobileadssdk:
Hi Nikita,

Mobile Ads SDK Forum Advisor

unread,
Aug 2, 2021, 3:12:22 PM8/2/21
to seim...@gmail.com, google-adm...@googlegroups.com
HI NIKita,

Thank you for your patience as we have looked into this. I received some feedback from our team. They have stated that this should have been resolved back in 2019 and should not be an issue. With that in mind they have asked what version of Unity you are using. As well as getting a sample app that shows this issue is still around.
Reply all
Reply to author
Forward
0 new messages