UnityにAdmobバナー広告を表示させたいのですが、表示できません。
エラーや警告は一つもなく、ただAdmobのDebug.Log()が表示されるだけです。
そのログの中に Dummy という文字がよく目立ちます。
表示する準備はできているのに、表示させる環境がないということでしょうか?
AndroidとWindows8.1をUSBで接続して「Build And Run」を実行しました。
ゲームは起動してくれるのですが、Admobバナー広告が表示されません。
Get StartedからBanner AdsのCreate Banner Viewまでを参考にしました。
修正するために確認したこと
・Google公式のMobile Ads Unity plugin
・SDK, JDK
・プラットフォームのターゲットをAndroid
・Android ResolverのForce Resolve
・Android StudioからSDK ToolsのGoogle Play Serviceをインストール
下の画像がAndroid StudioのSDK Toolsでインストールしたものなんですが、他にインストールが必要なものってありますか?
コードはGet Startedからコピーしました。各IDは自分のAdMobコンソール画面に書いてあるものに変更しました。
広告を表示させるためのスクリプト↓
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using GoogleMobileAds.Api; 5public class GoogleMobileAdsScript : MonoBehaviour 6{ 7 private BannerView bannerView; 8 public void Start() 9 { 10 string appId = "自分のアプリIDを入力しました"; 11 12 // Initialize the Google Mobile Ads SDK. 13 MobileAds.Initialize(appId); 14 15 this.RequestBanner(); 16 } 17 18 private void RequestBanner() 19 { 20 string adUnitId = "自分の広告IDを入力しました"; 21 22 // Create a 320x50 banner at the top of the screen. 23 bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom); 24 25 // Create an empty ad request. 26 AdRequest request = new AdRequest.Builder().Build(); 27 28 // Load the banner with the request. 29 bannerView.LoadAd(request); 30 } 31}
コンソールログ↓
1:
Starting auto-resolution before scene build...
UnityEngine.Debug:Log(Object)
Google.Logger:Log(String, LogLevel)
GooglePlayServices.PlayServicesResolver:Log(String, LogLevel)
GooglePlayServices.PlayServicesResolver:OnPostProcessScene()
UnityEditor.Build.BuildPipelineInterfaces:OnSceneProcess(Scene, BuildReport)
2:
Dummy .ctor
UnityEngine.Debug:Log(Object)
GoogleMobileAds.Common.DummyClient:.ctor() (at Assets/GoogleMobileAds/Common/DummyClient.cs:28)
GoogleMobileAds.GoogleMobileAdsClientFactory:MobileAdsInstance() (at Assets/GoogleMobileAds/Platforms/GoogleMobileAdsClientFactory.cs:87)
System.Reflection.MethodBase:Invoke(Object, Object[])
GoogleMobileAds.Api.MobileAds:GetMobileAdsClient() (at Assets/GoogleMobileAds/Api/MobileAds.cs:54)
GoogleMobileAds.Api.MobileAds:.cctor() (at Assets/GoogleMobileAds/Api/MobileAds.cs:24)
GoogleMobileAdsScript:Start() (at Assets/Scripts/GoogleMobileAdsScript.cs:16)
GoogleMobileAdsScript:Start() (at Assets/Scripts/GoogleMobileAdsScript.cs:13)
3:
Dummy Initialize
UnityEngine.Debug:Log(Object)
GoogleMobileAds.Common.DummyClient:Initialize(String) (at Assets/GoogleMobileAds/Common/DummyClient.cs:70)
GoogleMobileAds.Api.MobileAds:Initialize(String) (at Assets/GoogleMobileAds/Api/MobileAds.cs:28)
GoogleMobileAdsScript:Start() (at Assets/Scripts/GoogleMobileAdsScript.cs:13)
4:
Dummy .ctor
UnityEngine.Debug:Log(Object)
GoogleMobileAds.Common.DummyClient:.ctor() (at Assets/GoogleMobileAds/Common/DummyClient.cs:28)
GoogleMobileAds.GoogleMobileAdsClientFactory:BuildBannerClient() (at Assets/GoogleMobileAds/Platforms/GoogleMobileAdsClientFactory.cs:27)
System.Reflection.MethodBase:Invoke(Object, Object[])
GoogleMobileAds.Api.BannerView:.ctor(String, AdSize, AdPosition) (at Assets/GoogleMobileAds/Api/BannerView.cs:34)
GoogleMobileAdsScript:RequestBanner() (at Assets/Scripts/GoogleMobileAdsScript.cs:23)
GoogleMobileAdsScript:Start() (at Assets/Scripts/GoogleMobileAdsScript.cs:15)
5:
Dummy CreateBannerView
UnityEngine.Debug:Log(Object)
GoogleMobileAds.Common.DummyClient:CreateBannerView(String, AdSize, AdPosition) (at Assets/GoogleMobileAds/Common/DummyClient.cs:90)
GoogleMobileAds.Api.BannerView:.ctor(String, AdSize, AdPosition) (at Assets/GoogleMobileAds/Api/BannerView.cs:35)
GoogleMobileAdsScript:RequestBanner() (at Assets/Scripts/GoogleMobileAdsScript.cs:23)
GoogleMobileAdsScript:Start() (at Assets/Scripts/GoogleMobileAdsScript.cs:15)
6:
Dummy LoadAd
UnityEngine.Debug:Log(Object)
GoogleMobileAds.Common.DummyClient:LoadAd(AdRequest) (at Assets/GoogleMobileAds/Common/DummyClient.cs:100)
GoogleMobileAds.Api.BannerView:LoadAd(AdRequest) (at Assets/GoogleMobileAds/Api/BannerView.cs:68)
GoogleMobileAdsScript:RequestBanner() (at Assets/Scripts/GoogleMobileAdsScript.cs:29)
GoogleMobileAdsScript:Start() (at Assets/Scripts/GoogleMobileAdsScript.cs:15)
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/10/26 10:24 編集
2018/10/26 10:29
2018/10/26 11:47
2018/10/26 15:39
2018/10/27 05:12
2018/10/27 06:34
2018/10/27 07:14
2018/10/27 08:01
2018/10/27 08:20
2018/10/27 08:22
2018/10/27 23:57 編集
2018/10/28 00:16