- Home /
Banner AdMob is not showing on Android
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
using System;
public class Ads : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
////Initialize Google Mobile Ads
MobileAds.Initialize(initStatus =>
{
Debug.Log("Calling the ad...");
});
////TODO: Remember to remove this before releasing the app.
List<string> deviceIds = new List<string>();
//This is the my device ID for testing
deviceIds.Add("MYDEVICEID");
RequestConfiguration requestConfiguration = new RequestConfiguration.Builder().SetTestDeviceIds(deviceIds).build();
MobileAds.SetRequestConfiguration(requestConfiguration);
}
}
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
Here is the link to the tutorial I followed. https://developers.google.com/admob/unity/ad-placements
Answer by Bill_G241 · Apr 25, 2021 at 08:18 PM
I checked the device log via Logcat on Android Studio and the below popup up to me:
2021-04-25 22:44:42.965 4191-4318/? I/Ads: GMA Debug BEGIN
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"}]}}
2021-04-25 22:44:42.965 4191-4318/? I/Ads: GMA Debug FINISH
2021-04-25 22:44:43.069 4191-4191/? I/Ads: Ad failed to load : 1
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. Now the problem is fixed.