Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
avatar image
0
Question by andycodes · Jun 29, 2018 at 09:29 PM · android buildadmobsdk

AdMob ads not working in Android Build Unity 2017.4.3f1

I've been trying for days to figure out how to implement admob ads into a unity project with little to no luck and it has become infuriating. the code below is a (verbatim) copy of the Admob getting started video here: https://youtu.be/UOptam261Ts

(The AdUnitId's are the provided by google Id's for running test ads.) GoogleMobileAdsDemoScript.cs :

 using UnityEngine;
 using GoogleMobileAds;
 using GoogleMobileAds.Api;
 using System;
 
 public class GoogleMobileAdsDemoScript : MonoBehaviour {
 
     private RewardBasedVideoAd rewardBasedVideoAd;
 
     public void Start() {
         rewardBasedVideoAd = RewardBasedVideoAd.Instance;
 
         // Called when an ad request has successfully loaded.
         rewardBasedVideoAd.OnAdLoaded += HandleRewardBasedVideoLoaded;
         // Called when an ad request failed to load.
         rewardBasedVideoAd.OnAdFailedToLoad += HandleRewardBasedVideoFailedToLoad;
         // Called when an ad is shown.
         rewardBasedVideoAd.OnAdOpening += HandleRewardBasedVideoOpened;
         // Called when the ad starts to play.
         rewardBasedVideoAd.OnAdStarted += HandleRewardBasedVideoStarted;
         // Called when the user should be rewarded for watching a video.
         rewardBasedVideoAd.OnAdRewarded += HandleRewardBasedVideoRewarded;
         // Called when the ad is closed.
         rewardBasedVideoAd.OnAdClosed += HandleRewardBasedVideoClosed;
         // Called when the ad click caused the user to leave the application.
         rewardBasedVideoAd.OnAdLeavingApplication += HandleRewardBasedVideoLeftApplication;
     }
 
     public void OnGUI()
     {
         GUIStyle style = new GUIStyle();
 
         Rect rect = new Rect(0, 0, Screen.width, Screen.height);
         style.alignment = TextAnchor.LowerRight;
         style.fontSize = (int)(Screen.height * 0.06f);
         style.normal.textColor = new Color(0f, 0f, .5f, 1f);
 
         GUI.skin.button.fontSize = (int)(0.035f * Screen.width);
         float buttonWidth = 0.35f * Screen.width;
         float buttonHeight = 0.15f * Screen.height;
         float columnOnePosition = 0.1f * Screen.width;
 
         Rect requestRewardRect = new Rect(columnOnePosition, 0.1f * Screen.height, buttonWidth, buttonHeight);
 
         Rect showRewardRect = new Rect(columnOnePosition, 0.3f * Screen.height, buttonWidth, buttonHeight);
 
         if (GUI.Button(requestRewardRect, "Request\nRewarded Video"))
         {
             LoadRewardBasedAd();
         }
 
         if (GUI.Button(showRewardRect, "Show\nRewarded Video"))
         {
             ShowRewardBasedAd();
         }
     }
 
     private void LoadRewardBasedAd() {
 #if UNITY_EDITOR
         string adUnitId = "unused";
 #elif UNITY_ANDROID
         string adUnitId = "ca-app-pub-3940256099942544/7325402514";
 #endif
         rewardBasedVideoAd.LoadAd(new AdRequest.Builder().Build(), adUnitId);
     }
 
     void ShowRewardBasedAd()
     {
         if (rewardBasedVideoAd.IsLoaded())
         {
             rewardBasedVideoAd.Show();
         }
         else print("Ad not ready!");
     }
 
 
     public void HandleRewardBasedVideoLoaded(object sender, EventArgs args)
     {
         MonoBehaviour.print("HandleRewardBasedVideoLoaded event received");
     }
 
     public void HandleRewardBasedVideoFailedToLoad(object sender, AdFailedToLoadEventArgs args)
     {
         MonoBehaviour.print(
             "HandleRewardBasedVideoFailedToLoad event received with message: "
                              + args.Message);
     }
 
     public void HandleRewardBasedVideoOpened(object sender, EventArgs args)
     {
         MonoBehaviour.print("HandleRewardBasedVideoOpened event received");
     }
 
     public void HandleRewardBasedVideoStarted(object sender, EventArgs args)
     {
         MonoBehaviour.print("HandleRewardBasedVideoStarted event received");
     }
 
     public void HandleRewardBasedVideoClosed(object sender, EventArgs args)
     {
         MonoBehaviour.print("HandleRewardBasedVideoClosed event received");
     }
 
     public void HandleRewardBasedVideoRewarded(object sender, Reward args)
     {
         string type = args.Type;
         double amount = args.Amount;
         MonoBehaviour.print(
             "HandleRewardBasedVideoRewarded event received for "
                         + amount.ToString() + " " + type);
     }
 
     public void HandleRewardBasedVideoLeftApplication(object sender, EventArgs args)
     {
         MonoBehaviour.print("HandleRewardBasedVideoLeftApplication event received");
     }
 }



Additionally, I have:

  • downloaded the most recent package from their GitHub repo

  • force-resolved Android dependencies and updated the version via unity menu options.

  • Updated my version of Unity ( to 2017.4.3f1 )

  • Run my Android in development build

  • Tried implementing other ad types such as banner.

  • Run my Android Build in ADB Logcat



When ran in adb using Adb Logcat -s Unity in the console, I get this error message though, as if the ad continuously fails to load and instead throws a timeout error. (I've tried many times to get it to work in the case that it could just be a timeout error, but no luck )


  HandleRewardBasedVideoFailedToLoad event received with message: Internal error
 06-29 16:14:50.664 31067 31067 I Unity   : UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
 06-29 16:14:50.664 31067 31067 I Unity   : UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
 06-29 16:14:50.664 31067 31067 I Unity   : UnityEngine.Logger:Log(LogType, Object)
 06-29 16:14:50.664 31067 31067 I Unity   : UnityEngine.Debug:Log(Object)
 06-29 16:14:50.664 31067 31067 I Unity   : UnityEngine.MonoBehaviour:print(Object)
 06-29 16:14:50.664 31067 31067 I Unity   : GoogleMobileAdsDemoScript:HandleRewardBasedVideoFailedToLoad(Object, AdFailedToLoadEventArgs) (at C:\





Does anyone have an idea of what I must be doing wrong here? any guidance would be greatly appreciated!



Also, if anyone is wondering about the scene, It is a simple scene with only a main camera and the GoogleMobileAdsDemoScript.cs attached as a component.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by gurbrindersingh · Mar 15, 2019 at 04:10 PM

Well, I would say to double check if you have turned on internet connection already or if firewall hasn't blocked anything.

Comment
Add comment · Share
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
avatar image
0

Answer by dstream · Aug 25, 2020 at 10:50 AM

thanks for your suggestion @gurbrindersingh

I setup a ad-blocker DNS in my internet modem long time ago and I forgot it :(

Comment
Add comment · Share
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

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

92 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

Related Questions

Failed to re-package resources Admob integration 0 Answers

Why cant I put ads in my game? 1 Answer

Unity keeps trying to install SDK tools after Admob integration 0 Answers

Error : Didn't find class "com.google.android.gms.ads.MobileAds" 0 Answers

App crash on launch. 1 Answer


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