Firebase
Crashlytics는
앱의 안정성 문제를 쉽게 관리할 수 있는 간단한 실시간 비정상 종료 보고 도구입니다. Crashlytics를 사용하면 비정상 종료를 지능적으로 분류하고
비정상 종료로 이어지는 상황을 식별하여 문제 해결 시간을
단축할 수 있습니다.
이 가이드에서는 Crashlytics를 Android 스튜디오 프로젝트에 통합하여 광고 응답 ID를 로깅하는 방법을 설명합니다. 나중에 앱의 비정상 종료 문제를 해결할 때 광고 응답 ID를 찾아 Ad Manager의 광고 심사 센터를 사용하여 광고를 찾고 차단할 수 있습니다.
1단계: Android 애플리케이션에 Firebase 추가
클린 앱에서 Firebase로 로깅하려면 GitHub에서 Android 저장소용 Google 모바일 광고 SDK 예를 다운로드하거나 클론하세요. 이 가이드에서는
배너 예를 사용합니다.
이미 앱이 있는 경우 앱의 패키지 이름으로 다른 단계를 진행할 수 있습니다. 저장소의 다른 예에도 동일한 단계를 약간 수정하여 적용할 수 있습니다.
Firebase Crashlytics를 사용하려면 Firebase 프로젝트를 만들고 프로젝트에 앱을 추가해야 합니다. 아직 Firebase 프로젝트가 없는 경우 프로젝트를 만드세요. 프로젝트에 앱을 등록해야 합니다.
Firebase Console의 Crashlytics 페이지에서 Crashlytics 설정을 클릭합니다.
표시되는 화면에서 아니요 > 새 Firebase 앱 설정을
클릭합니다.
build.gradle에 Google 애널리틱스, Fabric, Crashlytics의 종속 항목을
추가합니다.
app/build.gradle
applyplugin:'com.android.application'applyplugin:'com.google.gms.google-services'// Add the Fabric pluginapplyplugin:'io.fabric'dependencies{// ...// Add the Google Mobile Ads SDKimplementation'com.google.android.gms:play-services-ads:24.5.0'// Add the Firebase Crashlytics dependency.implementation'com.google.firebase:firebase-crashlytics:20.0.1'}
Android 스튜디오에서 에뮬레이터 또는 연결된 기기에 앱을 빌드하고 실행합니다.
앱이 로드된 후 비정상 종료 버튼을 클릭할 수 있습니다. 기기 또는 Android 스튜디오에서 앱을 다시 실행하여 비정상 종료 로그를 Crashlyics에 업로드합니다.
2단계: 광고 응답 ID 로깅
여러 광고를 로드하여 서로 다른 시간에 게재하는 경우 별도의 키로
각 광고 응답 ID를 로깅하는 것이 좋습니다. 예를 들어 이 가이드에서는 배너 광고가 하나만 있는 예를 사용합니다. 따라서 광고 응답 ID는 다음 스니펫의
banner_ad_response_id 키로 로깅됩니다. Firebase Crashlytics에서
다양한 광고 유형과 광고 이벤트에 대해 여러 개의 맞춤 키 / 값 쌍을
만들 수 있습니다 (광고의
수명 주기는
AdListener 참고). 맞춤 로깅에 대한 자세한 내용은 Firebase Crashlytics 비정상 종료 보고서 맞춤설정을 참고하세요.
MyActivity.java에 다음 코드를 추가합니다. 기본적으로 onAdLoaded() 콜백 함수의
FirebaseCrashlytics.setCustomKey() 함수를 사용하여
getResponseInfo() 호출을 시도하기 전에
광고가 로드되도록 합니다.
[null,null,["최종 업데이트: 2025-08-31(UTC)"],[[["\u003cp\u003eFirebase Crashlytics is integrated to help you manage app stability by grouping crashes and highlighting their causes.\u003c/p\u003e\n"],["\u003cp\u003eThe guide outlines how to set up Crashlytics in your Android project to log ad response IDs for troubleshooting in Ad Manager's Ad Review Center.\u003c/p\u003e\n"],["\u003cp\u003eYou can test the Crashlytics setup by adding a crash button to trigger a crash and observe the logs in the Firebase console.\u003c/p\u003e\n"],["\u003cp\u003eAfter setup, log the ad response ID as a custom key in Crashlytics using \u003ccode\u003eFirebaseCrashlytics.setCustomKey()\u003c/code\u003e within the \u003ccode\u003eonAdLoaded()\u003c/code\u003e callback.\u003c/p\u003e\n"],["\u003cp\u003eCrash reports with the logged ad response ID will be available in your Crashlytics dashboard, enabling you to identify and block problematic ads.\u003c/p\u003e\n"]]],["Firebase Crashlytics, a crash reporter, is integrated into an Android app to log ad response IDs for troubleshooting. Key actions include: creating a Firebase project, registering the app, and adding dependencies for Google Analytics, Fabric, and Crashlytics in `build.gradle`. A crash button is optionally added for testing. The ad response ID is then logged using `FirebaseCrashlytics.setCustomKey()` in the `onAdLoaded()` callback, associating the \"banner_ad_response_id\" key with the ID. This enables tracking ad-related crashes via the Crashlytics dashboard, enabling better debugging.\n"],null,["Select platform: [Android](/ad-manager/mobile-ads-sdk/android/crashlytics \"View this page for the Android platform docs.\") [iOS](/ad-manager/mobile-ads-sdk/ios/crashlytics \"View this page for the iOS platform docs.\") [Unity](/ad-manager/mobile-ads-sdk/unity/crashlytics \"View this page for the Unity platform docs.\")\n\n\u003cbr /\u003e\n\n[Firebase\nCrashlytics](//firebase.google.com/docs/crashlytics/get-started-new-sdk?platform=android)\nis a lightweight, realtime crash reporter that makes it easy for you to manage\nstability issues in your app. Crashlytics saves you troubleshooting time by\nintelligently grouping crashes and highlighting the circumstances that lead up\nto them.\n\nThis guide describes how to integrate Crashlytics into your Android Studio\nproject so that you can log ad response IDs. Later, when you troubleshoot\ncrashes in your app, you can look up the ad response ID and use the Ad Review\nCenter in\n\n[Ad Manager](//support.google.com/admanager/answer/173120)\n\nto find and block the ads.\n\n**Step 1:** Add Firebase to an Android application\n\n1. If you would like to try logging with Firebase from a clean app, you can\n download or clone the Google Mobile Ads SDK examples for Android\n [repository](//github.com/googleads/googleads-mobile-android-examples) on\n GitHub. This guide specifically uses the\n\n [Banner Example](//github.com/googleads/googleads-mobile-android-examples/tree/main/java/admanager/BannerExample).\n\n\n If you already have an app, you should be able to proceed to other steps\n with your app's package name. The same steps can also be applied to other\n examples in the repository with minor adaptations.\n2. In order to use Firebase Crashlytics, you must create a Firebase project and\n add your app to it. If you haven't already, create a Firebase project. Make\n sure to [register your\n app](//firebase.google.com/docs/android/setup#register-app) to it.\n\n 1. In the Crashlytics page of the Firebase console, click **Set up\n Crashlytics**.\n\n 2. In the screen that appears, click **No** \\\u003e **Set up a new Firebase\n app**.\n\n3. In your build.gradle, add the dependencies for Google Analytics, Fabric, and\n Crashlytics.\n\n app/build.gradle \n\n ```carbon\n apply plugin: 'com.android.application'\n apply plugin: 'com.google.gms.google-services'\n\n // Add the Fabric plugin\n apply plugin: 'io.fabric'\n\n dependencies {\n // ...\n\n // Add the Google Mobile Ads SDK\n implementation 'com.google.android.gms:play-services-ads:24.5.0'\n\n // Add the Firebase Crashlytics dependency.\n implementation 'com.google.firebase:firebase-crashlytics:20.0.1'\n }\n ```\n\n project/build.gradle \n\n ```text\n buildscript {\n repositories {\n // ...\n // Add Google's Maven repository.\n google()\n }\n\n dependencies {\n // ...\n\n classpath 'com.google.gms:google-services:4.4.3'\n\n // Add the Fabric Crashlytics plugin.\n classpath 'com.google.firebase:firebase-crashlytics-gradle:3.0.6'\n }\n }\n\n allprojects {\n // ...\n repositories {\n // Check that Google's Maven repository is included (if not, add it).\n google()\n\n // ...\n }\n }\n ```\n4. Build and run your app to make sure to make sure Crashlytics is configured\n correctly. Once successful, you will be able to access the Crashlytics\n dashboard.\n\n**(Optional): Test your Setup**\n\nBy [Adding a crash\nbutton](//firebase.google.com/docs/crashlytics/test-implementation?platform=android)\nyou can force a crash for causing an app crash with each button press.\n\nHere's an example that shows how to add a crash button in the `onCreate()` method of an\n`Activity`:\n\nMainActivity (excerpt) \n\nJava \n\n```java\nprotected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_my);\n\n // Gets the ad view defined in layout/ad_fragment.xml with ad unit ID set in\n // values/strings.xml.\n adView = findViewById(R.id.ad_view);\n\n // Start loading the ad in the background.\n adView.loadAd(new AdManagerAdRequest.Builder().build());\n\n // Add a crash button.\n Button crashButton = new Button(this);\n crashButton.setText(\"Crash!\");\n crashButton.setOnClickListener(new View.OnClickListener() {\n public void onClick(View view) {\n throw new RuntimeException(\"Test Crash\"); // Force a crash\n }\n });\n\n addContentView(crashButton, new ViewGroup.LayoutParams(\n ViewGroup.LayoutParams.MATCH_PARENT,\n ViewGroup.LayoutParams.WRAP_CONTENT));\n}\n```\n\nKotlin \n\n```kotlin\noverride fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n setContentView(R.layout.activity_my)\n\n // Gets the ad view defined in layout/ad_fragment.xml with ad unit ID set in\n // values/strings.xml.\n adView = findViewById(R.id.ad_view)\n\n // Start loading the ad in the background.\n adView.loadAd(AdManagerAdRequest.Builder().build())\n\n // Add a crash button.\n val crashButton = Button(this)\n crashButton.text = \"Crash!\"\n crashButton.setOnClickListener {\n throw RuntimeException(\"Test Crash\") // Force a crash\n }\n\n addContentView(crashButton, ViewGroup.LayoutParams(\n ViewGroup.LayoutParams.MATCH_PARENT,\n ViewGroup.LayoutParams.WRAP_CONTENT))\n}\n```\n\nIn Android Studio, build and run your app on an emulator or a connected device.\nAfter the app is loaded, you can click the **Crash** button. Relaunch the app\nfrom the device or Android Studio for the crash log to be uploaded to\nCrashlyics.\n| **Key Point:** While the crash and session data might be visible instantly in the Firebase console, custom keys may take an hour or more to propagate.\n\n**Step 2:** Log the ad response ID\n\nIf you load multiple ads and show them at different times, it is a good idea to\nlog each ad response Id with a separate key. For instance, this guide uses an\nexample that has only one banner ad. Hence, we log the ad response ID as the\n`banner_ad_response_id` key in the following snippet. Indeed you can create\nmultiple custom key / value pairs in Firebase Crashlytics for different ad types\nand ad events (see\n[`AdListener`](/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/AdListener) for\nad's life cycle). Visit [Customize your Firebase Crashlytics crash\nreports](//firebase.google.com/docs/crashlytics/customize-crash-reports?platform=android)\nfor more information on custom logging.\n\nAdd the following code to your `MyActivity.java`. Essentially, it uses the\n[`FirebaseCrashlytics.setCustomKey()`](//firebase.google.com/docs/reference/android/com/google/firebase/crashlytics/FirebaseCrashlytics#public-void-setcustomkey-string-key,-long-value)\nfunction in the `onAdLoaded()` callback function to ensure that the ad has\nloaded before attempting to call `getResponseInfo()`. \n\nJava \n\n```java\nprotected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_my);\n\n // Gets the ad view defined in layout/ad_fragment.xml with ad unit ID set in\n // values/strings.xml.\n adView = findViewById(R.id.ad_view);\n\n adView.setAdListener(new AdListener() {\n @Override\n public void onAdLoaded() {\n String adResponseId = adView.getResponseInfo().getResponseId();\n FirebaseCrashlytics.getInstance().setCustomKey(\n \"banner_ad_response_id\", adResponseId);\n }\n });\n\n // Start loading the ad in the background.\n adView.loadAd(new AdManagerAdRequest.Builder().build());\n\n // Add a crash button.\n Button crashButton = new Button(this);\n crashButton.setText(\"Crash!\");\n crashButton.setOnClickListener(new View.OnClickListener() {\n public void onClick(View view) {\n throw new RuntimeException(\"Test Crash\"); // Force a crash\n }\n });\n\n addContentView(crashButton, new ViewGroup.LayoutParams(\n ViewGroup.LayoutParams.MATCH_PARENT,\n ViewGroup.LayoutParams.WRAP_CONTENT));\n}\n```\n\nKotlin \n\n```kotlin\noverride fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n setContentView(R.layout.activity_my)\n\n // Gets the ad view defined in layout/ad_fragment.xml with ad unit ID set in\n // values/strings.xml.\n adView = findViewById(R.id.ad_view)\n\n adView.adListener = object : AdListener() {\n override fun onAdLoaded() {\n mAdView.responseInfo?.responseId?.let { adResponseId -\u003e\n FirebaseCrashlytics.getInstance().setCustomKey(\n \"banner_ad_response_id\", adResponseId)\n }\n }\n }\n\n // Start loading the ad in the background.\n adView.loadAd(AdManagerAdRequest.Builder().build())\n\n // Add a crash button.\n val crashButton = Button(this)\n crashButton.text = \"Crash!\"\n crashButton.setOnClickListener {\n throw RuntimeException(\"Test Crash\") // Force a crash\n }\n\n addContentView(crashButton, ViewGroup.LayoutParams(\n ViewGroup.LayoutParams.MATCH_PARENT,\n ViewGroup.LayoutParams.WRAP_CONTENT))\n}\n```\n\nCongratulations! You will now see the most recent `banner_ad_response_id`\nin the key section of crash sessions on your Crashlytics dashboard. Note that\nsome keys may take up to an hour to become visible in your dashboard."]]