-
[UNITY] Google 에서 제공하는 Admob 플러그인 사용시 Crash로 게임 실행이 안될때Develop/Tips 2019. 1. 3. 16:54반응형
https://github.com/googleads/googleads-mobile-unity 에서 다운 받은 플러그인을 적용하여 애드몹을 사용하는데
게임 실행 시 아래와 같은 충돌 메시지와 함께 게임이 종료되는 경우가 있습니다.
****************************************************************************** * The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers * * should follow the instructions here: https://goo.gl/fQ2neu to add a valid * * App ID inside the AndroidManifest. Google Ad Manager publishers should * * follow instructions here: https://goo.gl/h17b6x. * ****************************************************************************** at android.app.ActivityThread.installProvider(ActivityThread.java:6621) at android.app.ActivityThread.installContentProviders(ActivityThread.java:6173) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6079) at android.app.ActivityThread.-wrap1(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1791) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:7002) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408) Caused by: java.lang.IllegalStateException: ****************************************************************************** * The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers * * should follow the instructions here: https://goo.gl/fQ2neu to add a valid * * App ID inside the AndroidManifest. Google Ad Manager publishers should * * follow instructions here: https://goo.gl/h17b6x. * ******************************************************************************
주로 애드몹을 초기화하는 단계에서 충돌이 발생한 경우인데요.
https://developers.google.com/admob/unity/start 이 글을 보시면 광고를 요청하기 전에
아래와 같이 App ID를 입력하여 초기화 하도록 되어 있습니다.
using GoogleMobileAds.Api; public class GoogleMobileAdsDemoScript : MonoBehaviour { public void Start() #if UNITY_ANDROID string appId = "ca-app-pub-3940256099942544~3347511713"; #elif UNITY_IPHONE string appId = "ca-app-pub-3940256099942544~1458002511" #else string appId = "unexpected_platform"; #endif // Initialize the Google Mobile Ads SDK. MobileAds.Initialize(appId); }
유니티 최신 버전에서는 위와 같이 코드를 작성해도 초기화에 실패하여 게임이 종료되는 경우도 있기도 합니다.
플러그인에서 포스트빌드로 App ID를 자동으로 AndroidManifest.xml 파일에 추가해주는 기능이 들어있는데,
이 기능이 정상적으로 동작하지 않아 발생하는 문제인 것 같습니다.
이럴 때에는 당황하지 마시고, Assets/Plugins/Android/GoogleMobileAdsPlugin 폴더에 포함되어 있는
AndroidManifest.xml 파일을 열어 아래와 같이 입력하시면 됩니다.
<?xml version="1.0" encoding="utf-8"?> <!-- This Google Mobile Ads plugin library manifest will get merged with your application's manifest, adding the necessary activity and permissions required for displaying ads. --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.google.unity.ads" android:versionName="1.0" android:versionCode="1"> <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" /> <application> <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="이 곳에 App Id를 입력해주세요."/> </application> </manifest>
반응형'Develop > Tips' 카테고리의 다른 글
[SWIFT] let 과 var의 차이 (0) 2019.12.15 [GPGS] 구글 플레이 게임 서비스 유니티 플러그인 사용 시 실시간 갱신 문제 (1) 2019.01.06 [C#,UI] 마우스 or 터치 입력 포지션이 UI 위에 있는지 체크하기 (0) 2018.11.20 [C#, INSPECTOR] 유니티 인스펙터를 빠르고 간단하게 커스텀하기 (0) 2018.11.11 [C#] 유니티 이벤트 함수 실행 순서 (0) 2018.11.06