Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

AdMob is not showing on Android

Discussion in 'Editor & General Support' started by BelalGawish, Apr 25, 2021.

  1. BelalGawish

    BelalGawish

    Joined:
    Sep 17, 2019
    Posts:
    5
    Hello,
    I've imported AdMob package for Unity and followed the instructions in this link.
    Also I've created Google AdMob account and currently activated and registered my Android device as a test device. While testing on game play, I receive debug.log notification of successful ad loading. But after creating a build to test on android device, the ad is not showing.
    Here is my code
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using GoogleMobileAds.Api;
    5. using System;
    6.  
    7. public class Ads : MonoBehaviour
    8. {
    9.  
    10.     // Start is called before the first frame update
    11.     void Start()
    12.     {
    13.         ////Initialize Google Mobile Ads
    14.         MobileAds.Initialize(initStatus =>
    15.         {
    16.             Debug.Log("Calling the ad...");
    17.         });
    18.  
    19.  
    20.         ////TODO: Remember to remove this before releasing the app.
    21.         List<string> deviceIds = new List<string>();
    22.         //This is the my device ID for testing
    23.         deviceIds.Add("MYDEVICEID");
    24.         RequestConfiguration requestConfiguration = new RequestConfiguration.Builder().SetTestDeviceIds(deviceIds).build();
    25.         MobileAds.SetRequestConfiguration(requestConfiguration);
    26.  
    27.  
    28.     }
    29. }
    On the inspector, I've chosen the Auto Load Enabled. Am I missing something?
    Unity version: 2019.4.21f1
    AdMob package version: 5.4.0.90
    Thanks
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,762
    Anything in the actual device logs (via
    adb logcat
    or however) ?
     
    BelalGawish likes this.
  3. BelalGawish

    BelalGawish

    Joined:
    Sep 17, 2019
    Posts:
    5
    This is from Logcat: but so far no ads are showing. Maybe it will show only after I publish the app?

    Code (CSharp):
    1. 2021-04-25 22:28:45.515 1617-1673/? I/Unity: MemoryManager: Using 'Dynamic Heap' Allocator.
    2. 2021-04-25 22:28:45.579 1617-1673/? I/Unity: SystemInfo CPU = ARM64 FP ASIMD AES, Cores = 8, Memory = 3788mb
    3. 2021-04-25 22:28:45.579 1617-1673/? I/Unity: SystemInfo ARM big.LITTLE configuration: 4 big (mask: 0xf0), 4 little (mask: 0xf)
    4. 2021-04-25 22:28:45.579 1617-1673/? I/Unity: ApplicationInfo com.Gamiation.LeaveCalc version 0.10 build b0fa314f-2826-4ab8-95aa-9cb8b9ce13ee
    5. 2021-04-25 22:28:45.579 1617-1673/? I/Unity: Built from '2019.4/staging' branch, Version '2019.4.21f1 (b76dac84db26)', Build type 'Release', Scripting Backend 'mono', CPU 'armeabi-v7a', Stripping 'Disabled'
    6. 2021-04-25 22:28:50.723 1617-1617/? D/AdsUnity: Calling loadAd() on Android
    Thanks
     
  4. BelalGawish

    BelalGawish

    Joined:
    Sep 17, 2019
    Posts:
    5
    I filtered the search on Logcat to I/Ads and I found this error:
    Code (CSharp):
    1. 2021-04-25 22:44:42.965 4191-4318/? I/Ads: GMA Debug BEGIN
    2. 2021-04-25 22:44:42.965 4191-4318/? I/Ads: GMA Debug CONTENT {"timestamp":1619379882965,"event":"onNetworkResponse","components":["network_request_36772ca1-01d5-4878-8f01-00d899c2bd16"],"params":{"firstline":{"code":200},"headers":[{"name":null,"value":"HTTP/1.1 200 OK"},{"name":"Alt-Svc","value":"h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\""},{"name":"Server","value":"sffe"},{"name":"X-Content-Type-Options","value":"nosniff"},{"name":"Last-Modified","value":"Thu, 03 Oct 2019 10:15:00 GMT"},{"name":"X-Android-Received-Millis","value":"1619379882964"},{"name":"Date","value":"Tue, 20 Apr 2021 11:02:55 GMT"},{"name":"Accept-Ranges","value":"bytes"},{"name":"X-Android-Selected-Protocol","value":"http/1.1"},{"name":"Cache-Control","value":"public, max-age=31536000"},{"name":"X-Android-Response-Source","value":"NETWORK 200"},{"name":"Vary","value":"Accept-Encoding"},{"name":"Cross-Origin-Resource-Policy","value":"cross-origin"},{"name":"Expires","value":"Wed, 20 Apr 2022 11:02:55 GMT"},{"name":"X-Android-Sent-Millis","value":"1619379882866"},{"name":"X-XSS-Protection","value":"0"},{"name":"Age","value":"463310"},{"name":"Content-Type","value":"image/x-icon"}]}}
    3. 2021-04-25 22:44:42.965 4191-4318/? I/Ads: GMA Debug FINISH
    4. 2021-04-25 22:44:43.069 4191-4191/? I/Ads: Ad failed to load : 1
    5.  
    So I searched for error codes and found it here: https://support.google.com/admob/thread/3494603?hl=en
    I figured out I was writing the Ad Unit ID wrong. I typed it correct and now the ads are showing on my test device.