[null,null,["最后更新时间 (UTC):2025-08-22。"],[[["\u003cp\u003eIntegrating the Google Mobile Ads SDK is the initial step to display ads in your app and generate revenue, followed by choosing an ad format (like native or rewarded video) and implementing it.\u003c/p\u003e\n"],["\u003cp\u003eBefore starting, ensure your app has a minimum SDK version of 21, a compile SDK version of 33 or higher, and is registered with AdMob to obtain a unique AdMob App ID.\u003c/p\u003e\n"],["\u003cp\u003eConfigure your app by including Google's and Maven Central's repositories, adding the Google Mobile Ads SDK dependency, and inserting your AdMob App ID in your \u003ccode\u003eAndroidManifest.xml\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eInitialize the Google Mobile Ads SDK before loading ads by calling \u003ccode\u003eMobileAds.initialize()\u003c/code\u003e once, preferably during app launch, to ensure all mediation adapters are initialized.\u003c/p\u003e\n"],["\u003cp\u003eChoose from various ad formats offered by AdMob, including banner, interstitial, native, rewarded, rewarded interstitial, and app open ads, to best suit your app's user experience.\u003c/p\u003e\n"]]],["To start displaying ads, integrate the Google Mobile Ads SDK into your app. Ensure your app's minimum SDK version is 21 or higher, and compile SDK is 34 or higher. Register your app in AdMob to get a unique App ID. Configure your app by including Google's Maven and Maven central repositories, adding SDK dependencies in the build file, and inserting your AdMob app ID into `AndroidManifest.xml`. Initialize the SDK with `MobileAds.initialize()` on app launch, preferably on a background thread. Choose an ad format (banner, interstitial, native, rewarded, rewarded interstitial, or app open) to implement.\n"],null,["Select platform: [Android](/admob/android/quick-start \"View this page for the Android platform docs.\") [iOS](/admob/ios/quick-start \"View this page for the iOS platform docs.\") [Unity](/admob/unity/quick-start \"View this page for the Unity platform docs.\") [Flutter](/admob/flutter/quick-start \"View this page for the Flutter platform docs.\")\n\n\u003cbr /\u003e\n\nIntegrating the Google Mobile Ads SDK into an app is the first step toward\ndisplaying ads and earning revenue. Once you've integrated the SDK, you can\nchoose an ad format (such as native or rewarded video) and follow the steps to\nimplement it.\n\nBefore you begin\n\nTo prepare your app, complete the steps in the following sections.\n\nApp prerequisites\n\n- Make sure that your app's build file uses the following values:\n\n - Minimum SDK version of `23` or higher\n - Compile SDK version of `34` or higher\n\nSet up your app in your AdMob account\n\nRegister your app as an AdMob app by completing the following steps:\n\n1. [Sign in to](//admob.google.com/home/) or [sign up\n for](//support.google.com/admob/answer/7356219) an AdMob account.\n\n2. [Register your app with AdMob](//support.google.com/admob/answer/2773509).\n This step creates an AdMob app with a unique [AdMob App\n ID](//support.google.com/admob/answer/7356431) that is needed later in this\n guide.\n\nConfigure your app\n\n1. In your Gradle settings file, include the\n [Google's Maven repository](//maven.google.com/web/index.html) and\n [Maven central repository](//search.maven.org/artifact):\n\n Kotlin \n\n ```kotlin\n pluginManagement {\n repositories {\n google()\n mavenCentral()\n gradlePluginPortal()\n }\n }\n\n dependencyResolutionManagement {\n repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)\n repositories {\n google()\n mavenCentral()\n }\n }\n\n rootProject.name = \"My Application\"\n include(\":app\")\n ```\n\n Groovy \n\n ```groovy\n pluginManagement {\n repositories {\n google()\n mavenCentral()\n gradlePluginPortal()\n }\n }\n\n dependencyResolutionManagement {\n repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)\n repositories {\n google()\n mavenCentral()\n }\n }\n\n rootProject.name = \"My Application\"\n include ':app'\n ```\n2. Add the dependencies for the Google Mobile Ads SDK to your app-level build\n file:\n\n Kotlin \n\n ```kotlin\n dependencies {\n implementation(\"com.google.android.gms:play-services-ads:24.4.0\")\n }\n ```\n\n Groovy \n\n ```groovy\n dependencies {\n implementation 'com.google.android.gms:play-services-ads:24.4.0'\n }\n ```\n3. Click **Sync Now** . For details on syncing, see\n [Sync projects with Gradle files](https://developers.android.com/build#sync-files).\n\n4. Add your AdMob app ID, as\n [identified in the AdMob web interface](//support.google.com/admob/answer/7356431),\n to your app's `AndroidManifest.xml` file. To do so, add a `\u003cmeta-data\u003e` tag\n with `android:name=\"com.google.android.gms.ads.APPLICATION_ID\"`. You can find\n your **app ID** in the AdMob web interface. For\n `android:value`, insert your own AdMob app ID,\n surrounded by quotation marks.\n\n \u003cmanifest\u003e\n \u003capplication\u003e\n \\\u003c!-- Sample AdMob app ID: ca-app-pub-3940256099942544\\~3347511713 --\\\u003e\n \\\u003cmeta-data\n android:name=\"com.google.android.gms.ads.APPLICATION_ID\"\n android:value=\"\u003cvar scope=\"SAMPLE_APP_ID\" translate=\"no\"\u003eSAMPLE_APP_ID\u003c/var\u003e\"/\\\u003e\n \u003c/application\u003e\n \u003c/manifest\u003e\n\n Replace \u003cvar scope=\"SAMPLE_APP_ID\" translate=\"no\"\u003eSAMPLE_APP_ID\u003c/var\u003e with your AdMob app ID. While\n testing, use the sample app ID shown in the previous example.\n\n Also, note that failure to add the `\u003cmeta-data\u003e` tag exactly as shown results\n in a crash with the message: \n\n Missing application ID.\n\n (Optional) Declare\n `AD_ID` permission for previous versions to work with Android\n 13.\n\n If your app uses the Google Mobile Ads SDK version **20.4.0** or\n higher, you can skip this step since the SDK automatically declares the\n `com.google.android.gms.permission.AD_ID` permission and is able\n to access the Advertising ID whenever it's available.\n\n For apps that use the Google Mobile Ads SDK version **20.3.0** or\n lower and are targeting Android 13, you must add the\n `com.google.android.gms.permission.AD_ID` permission in the\n `AndroidManifest.xml` file for the Google Mobile Ads SDK to\n access the Advertising ID: \n\n ```xml\n \u003cmanifest\u003e\n \u003capplication\u003e\n \u003cmeta-data\n android:name=\"com.google.android.gms.ads.APPLICATION_ID\"\n android:value=\"ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy\"/\u003e\n\n \u003c!-- For apps targeting Android 13 or higher & GMA SDK version 20.3.0 or lower --\u003e\n \u003cuses-permission android:name=\"com.google.android.gms.permission.AD_ID\"/\u003e\n\n \u003c/application\u003e\n \u003c/manifest\u003e\n ```\n\n To learn more about the\n `com.google.android.gms.permission.AD_ID` permission declaration,\n including how to disable it, refer to this [Play\n Console article](//support.google.com/googleplay/android-developer/answer/6048248).\n\nInitialize the Google Mobile Ads SDK Before loading ads, initialize the Google Mobile Ads SDK by calling [`MobileAds.initialize()`](/admob/android/reference/com/google/android/gms/ads/MobileAds#initialize(android.content.Context,%20com.google.android.gms.ads.initialization.OnInitializationCompleteListener)).\n\nThis method initializes the SDK and calls a completion listener once both the\nGoogle Mobile Ads SDK and adapter initializations have completed, or after a\n30-second timeout. This needs to be done only once, ideally at app launch.\n| **Note:** If you're using AdMob Mediation, wait until the completion handler is called before loading ads. This ensures that all mediation adapters are initialized.\n\n**Ads may be preloaded by the Google Mobile Ads SDK or mediation partner SDKs\nupon initialization.** If you need to obtain consent from users in the European\nEconomic Area (EEA), set any request-specific flags, such as\n\n[`setTagForChildDirectedTreatment()`](/admob/android/reference/com/google/android/gms/ads/RequestConfiguration.Builder#setTagForChildDirectedTreatment(int))\nor\n[`setTagForUnderAgeOfConsent()`](/admob/android/reference/com/google/android/gms/ads/RequestConfiguration.Builder#setTagForUnderAgeOfConsent(int)),\n\nor\notherwise take action before loading ads, ensure you do so before initializing\nthe Google Mobile Ads SDK.\n\nHere's an example of how to call the `initialize()` method on a background\nthread within an Activity: \n\nJava \n\n new Thread(\n () -\u003e {\n // Initialize the Google Mobile Ads SDK on a background thread.\n MobileAds.initialize(this, initializationStatus -\u003e {});\n })\n .start(); \n https://github.com/googleads/googleads-mobile-android-examples/blob/09de26aed1759c87354f4dea12ba3937fa51cf58/java/admob/BannerExample/app/src/main/java/com/google/android/gms/example/bannerexample/MyActivity.java#L195-L204\n\nKotlin \n\n CoroutineScope(Dispatchers.IO).launch {\n // Initialize the Google Mobile Ads SDK on a background thread.\n MobileAds.initialize(this@MainActivity) {}\n } \n https://github.com/googleads/googleads-mobile-android-examples/blob/09de26aed1759c87354f4dea12ba3937fa51cf58/kotlin/admob/BannerExample/app/src/main/java/com/google/android/gms/example/bannerexample/MainActivity.kt#L167-L176\n\nSelect an ad format\n\nThe Google Mobile Ads SDK is now imported and you're ready to implement an ad.\nAdMob offers a number of different ad formats, so\nyou can choose the one that best fits your app's user experience.\n\nBanner\n\nBanner ad units display rectangular ads that occupy a portion of an app's\nlayout. They can refresh automatically after a set period of time. This means\nusers view a new ad at regular intervals, even if they stay on the same\nscreen in your app. They're also the simplest ad format to implement. \n\n[Implement banner ads](/admob/android/banner)\n\nInterstitial\n\nInterstitial ad units show full-page ads in your app. Place them at natural\nbreaks and transitions in your app's interface, such as after level completion\nin a gaming app. \n\n[Implement interstitial ads](/admob/android/interstitial)\n\nNative\n\nNative ads are ads where you can customize the way assets such as headlines and\ncalls to action are presented in your apps. By styling the ad yourself, you can\ncreate a natural, unobtrusive ad presentations that can add to a rich user\nexperience. \n\n[Implement native ads](/admob/android/native)\n\nRewarded\n\nRewarded ad units enable users to play games, take surveys, or watch videos to\nearn in-app rewards, such as coins, extra lives, or points. You can set\ndifferent rewards for different ad units, and specify the reward values and\nitems the user received. \n\n[Implement rewarded ads](/admob/android/rewarded)\n\nRewarded interstitial\n\nRewarded interstitial is a new type of incentivized ad format that lets you\noffer rewards, such as coins or extra lives, for ads that appear automatically\nduring natural app transitions.\n\nUnlike rewarded ads, users aren't required to opt in to view a rewarded\ninterstitial.\n\nInstead of the opt-in prompt in rewarded ads, rewarded interstitials require an\nintro screen that announces the reward and gives users a chance to opt out if\nthey want to do so. \n\n[Implement rewarded interstitial ads](/admob/android/rewarded-interstitial)\n\nApp open\n\nApp open is an ad format that appears when users open or switch back to your\napp. The ad overlays the loading screen. \n\n[Implement app open ads](/admob/android/app-open)\n\nAdditional resources\n\nThe [Google Mobile Ads repository](//github.com/googleads/googleads-mobile-android-examples) on GitHub demonstrates\nhow to use the different ad formats that this API offers."]]