반응형
오류 내용
에디터에서는 테스트 id를 사용하여 광고를 로드하면 테스트 광고가 잘 나오지만 직접 발급받은 id로 로드 시 광고가 로드되지 않는 현상
해결 방법
1. AdMob 계정 설정 확인
a. 애드몹 앱 설정
- AdMob 계정에 로그인하여 애플리케이션이 올바르게 설정되었는지 확인합니다.
- 광고 단위 ID (Ad Unit ID)가 올바르게 설정되어 있는지 확인합니다. 실제 광고 단위 ID를 사용해야 합니다.
b. 광고 단위 ID
- 테스트 광고 단위 ID가 아닌 실제 광고 단위 ID를 사용해야 합니다. 테스트 광고 단위 ID는 다음과 같습니다:
- 배너 광고: ca-app-pub-3940256099942544/6300978111
- 전면 광고: ca-app-pub-3940256099942544/1033173712
- 보상형 광고: ca-app-pub-3940256099942544/5224354917
- 실제 광고를 요청할 때는 AdMob 계정에서 생성한 실제 광고 단위 ID를 사용해야 합니다.
2. 코드 설정 확인
a. AdMob 초기화 코드
- AdMob 초기화가 올바르게 설정되었는지 확인합니다.
using GoogleMobileAds.Api;
using UnityEngine;
public class AdMobManager : MonoBehaviour
{
private BannerView bannerView;
private InterstitialAd interstitial;
private RewardedAd rewardedAd;
void Start()
{
// Initialize the Google Mobile Ads SDK.
MobileAds.Initialize(initStatus => { });
// Load a banner ad.
this.RequestBanner();
// Load an interstitial ad.
this.RequestInterstitial();
// Load a rewarded ad.
this.RequestRewardedAd();
}
private void RequestBanner()
{
string adUnitId = "your-banner-ad-unit-id";
this.bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);
AdRequest request = new AdRequest.Builder().Build();
this.bannerView.LoadAd(request);
}
private void RequestInterstitial()
{
string adUnitId = "your-interstitial-ad-unit-id";
this.interstitial = new InterstitialAd(adUnitId);
AdRequest request = new AdRequest.Builder().Build();
this.interstitial.LoadAd(request);
}
private void RequestRewardedAd()
{
string adUnitId = "your-rewarded-ad-unit-id";
this.rewardedAd = new RewardedAd(adUnitId);
AdRequest request = new AdRequest.Builder().Build();
this.rewardedAd.LoadAd(request);
}
}
3. Android 설정 확인
a. AndroidManifest.xml
- AndroidManifest.xml 파일에 AdMob 관련 권한과 메타데이터가 올바르게 설정되었는지 확인합니다.
<manifest>
<application>
<!-- Add your AdMob App ID -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="your-admob-app-id"/>
</application>
</manifest>
b. ProGuard 설정
- ProGuard를 사용하는 경우, AdMob 라이브러리를 보호하기 위한 설정이 필요합니다.
-keep public class com.google.android.gms.ads.** { *; }
-keep public class com.google.ads.** { *; }
4. 디버깅 및 로그 확인
a. 디버깅
- 로그를 통해 광고 로드 실패의 원인을 확인할 수 있습니다. 다음과 같은 로그를 추가하여 문제를 진단합니다.
void Start()
{
MobileAds.Initialize(initStatus => {
Debug.Log("AdMob initialized.");
});
this.RequestBanner();
}
private void RequestBanner()
{
string adUnitId = "your-banner-ad-unit-id";
this.bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);
AdRequest request = new AdRequest.Builder().Build();
// Attach events to catch failures.
this.bannerView.OnAdFailedToLoad += HandleOnAdFailedToLoad;
this.bannerView.LoadAd(request);
}
public void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
Debug.LogError("Banner ad failed to load: " + args.LoadAdError);
}
빠른 해결
유니티로 제작된 게임을 업그레이드 해드립니다. - 크몽
DevPark 전문가의 IT·프로그래밍 서비스를 만나보세요. <p><strong style="font-size: 24px;&q...
kmong.com
반응형