前提・実現したいこと
Unityで作成したゲームにAdMobのバナー広告を実装したい。
バージョンについて
・Unity : ver.2019.3.5f1
・実機(スマホ)のgoogleplay開発者サービス : (ver.20.15.16040406-309763488)
・Target Android APIレベル : File → BuildSetting → Player → OtherSettingで確認すると、Automatic(highest Installed)になっています。
公式サイトのスタートアップに記載されている前提条件はクリアできていると考えています。
リンク内容
発生している問題・エラーメッセージ
Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.IOSResolver_v1.2.153 2.dll has no meta file, but it's in an immutable folder. The asset will be ignored. Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.IOSResolver_v1.2.153.dll 2.mdb has no meta file, but it's in an immutable folder. The asset will be ignored. sset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.JarResolver_v1.2.153 2.dll has no meta file, but it's in an immutable folder. The asset will be ignored. Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.JarResolver_v1.2.153.dll 2.mdb has no meta file, but it's in an immutable folder. The asset will be ignored. Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.PackageManagerResolver_v1.2.153 2.dll has no meta file, but it's in an immutable folder. The asset will be ignored. Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.PackageManagerResolver_v1.2.153.dll 2.mdb has no meta file, but it's in an immutable folder. The asset will be ignored. Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.VersionHandler 2.dll has no meta file, but it's in an immutable folder. The asset will be ignored. Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.VersionHandler.dll 2.mdb has no meta file, but it's in an immutable folder. The asset will be ignored. Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.VersionHandlerImpl_v1.2.153 2.dll has no meta file, but it's in an immutable folder. The asset will be ignored. Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.VersionHandlerImpl_v1.2.153.dll 2.mdb has no meta file, but it's in an immutable folder. The asset will be ignored. Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.IOSResolver_v1.2.153 2.dll has no meta file, but it's in an immutable folder. The asset will be ignored. UnityEditor.AssetDatabase:Refresh() Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.IOSResolver_v1.2.153.dll 2.mdb has no meta file, but it's in an immutable folder. The asset will be ignored. UnityEditor.AssetDatabase:Refresh() Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.JarResolver_v1.2.153 2.dll has no meta file, but it's in an immutable folder. The asset will be ignored. UnityEditor.AssetDatabase:Refresh() Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.JarResolver_v1.2.153.dll 2.mdb has no meta file, but it's in an immutable folder. The asset will be ignored. UnityEditor.AssetDatabase:Refresh() Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.PackageManagerResolver_v1.2.153 2.dll has no meta file, but it's in an immutable folder. The asset will be ignored. UnityEditor.AssetDatabase:Refresh() Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.PackageManagerResolver_v1.2.153.dll 2.mdb has no meta file, but it's in an immutable folder. The asset will be ignored. UnityEditor.AssetDatabase:Refresh() Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.VersionHandler 2.dll has no meta file, but it's in an immutable folder. The asset will be ignored. UnityEditor.AssetDatabase:Refresh() Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.VersionHandler.dll 2.mdb has no meta file, but it's in an immutable folder. The asset will be ignored. UnityEditor.AssetDatabase:Refresh() Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.VersionHandlerImpl_v1.2.153 2.dll has no meta file, but it's in an immutable folder. The asset will be ignored. UnityEditor.AssetDatabase:Refresh() Asset Packages/com.google.external-dependency-manager/ExternalDependencyManager/Editor/Google.VersionHandlerImpl_v1.2.153.dll 2.mdb has no meta file, but it's in an immutable folder. The asset will be ignored. UnityEditor.AssetDatabase:Refresh()
該当のソースコード
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using GoogleMobileAds.Api; 5 6public class AdsManager : MonoBehaviour 7{ 8 // Start is called before the first frame update 9 void Start() 10 { 11 // アプリID 12 string appId = "ca-app-pub-3533347070899259~2019130540"; 13 14 // Initialize the Google Mobile Ads SDK. 15 MobileAds.Initialize(appId); 16 17 RequestBanner(); 18 } 19 20 private void RequestBanner() 21 { 22 23 // 広告ユニットID 24 string adUnitId = "ca-app-pub-3533347070899259/1029003577"; 25 26 // Create a 320x50 banner at the top of the screen. 27 BannerView bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom); 28 29 // Create an empty ad request. 30 AdRequest request = new AdRequest.Builder().Build(); 31 32 // Load the banner with the request. 33 bannerView.LoadAd(request); 34 35 } 36 37 // Update is called once per frame 38 void Update() 39 { 40 41 } 42}
試したこと
まず、UnityでAdMobのパッケージ(ver.5.1.0)をAssetにImportし、
Asset → GoogleMobileAds → Setting でGoogleAdMobにチェックを入れてAdMob App IDにアプリIDを入力(下図参照)
次に、当該ソースコードの欄で記載したスクリプトを空のGameObjectにAttachすると、多量のエラーが発生。
エラーの内容を読んでもさっぱり理解できず・・・。
<以下、試したこと>
Visual Studio上で、ソースコードの15行目が旧形式だと指摘があり、どうすればいいかわからず、公式サイトのスタートガイドを参考にしてMobileAds.Initialize(appId); → MobileAds.Initialize(initStatus => { });
に変更しましたが解決ならず。(ラムダ式?に変更しました。下図参照)
古いバージョンのパッケージだと実装できたという記事をネットで見かけたので、
ver.3.4.0で同じことを試しましたが解決に至りませんでした。
他に、App IDと広告ユニットIDのうち間違えはなさそうです。
エラーを無視してAndroidでBuildを試みましたが予想通りFailedでした。
補足情報(FW/ツールのバージョンなど)
バージョンについては既に記載しました。
teratail内で似た質問がいくつかあり、確認したのですが同じエラーのものは見つけられませんでした。
他に必要な情報があれば、ご指摘お願いいたします。
あなたの回答
tips
プレビュー