يُعدّ دمج حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" في تطبيقك الخطوة الأولى نحو عرض الإعلانات وتحقيق الإيرادات. بعد دمج حزمة SDK، يمكنك اختيار تنسيق إعلان (مثل الإعلان الأصلي أو الفيديو مقابل مكافأة) واتّباع الخطوات لتنفيذه.
قبل البدء
لإعداد تطبيقك، أكمِل الخطوات الواردة في الأقسام التالية.
المتطلبات الأساسية للتطبيق
تأكَّد من أنّ ملف الإصدار في تطبيقك يستخدم القيم التالية:
إصدار حزمة تطوير البرامج (SDK) 23 أو إصدار أحدث
إصدار حزمة تطوير البرامج (SDK) الذي تم تجميعه
34
أو إصدار أحدث
إعداد تطبيقك في حسابك على AdMob
سجِّل تطبيقك كتطبيق على AdMob من خلال إكمال الخطوات التالية:
أضِف معرّف تطبيقك على AdMob، كما هو محدّد في واجهة مستخدم AdMob على الويب، إلى ملف AndroidManifest.xml الخاص بتطبيقك. لإجراء ذلك، أضِف علامة <meta-data>
مع android:name="com.google.android.gms.ads.APPLICATION_ID". يمكنك العثور على رقم تعريف تطبيقك في واجهة الويب الخاصة بخدمة AdMob. بالنسبة إلى
android:value، أدخِل رقم تعريف تطبيقك على AdMob
بين علامتَي اقتباس.
استبدِل SAMPLE_APP_ID بمعرّف تطبيقك على AdMob. أثناء الاختبار، استخدِم معرّف التطبيق النموذجي الموضّح في المثال السابق.
يُرجى أيضًا العِلم أنّه في حال عدم إضافة العلامة <meta-data> كما هو موضّح تمامًا، سيحدث تعطُّل مع ظهور الرسالة التالية:
Missing application ID.
(اختياري) يمكنك بيان
إذن AD_ID للإصدارات السابقة لكي تعمل مع نظام التشغيل Android 13.
إذا كان تطبيقك يستخدم الإصدار 20.4.0 أو إصدارًا أحدث من حزمة تطوير البرامج (SDK) لإعلانات Google على الأجهزة الجوّالة، يمكنك تخطّي هذه الخطوة لأنّ حزمة تطوير البرامج (SDK) تقدّم بيان الإذن com.google.android.gms.permission.AD_ID تلقائيًا ويمكنها الوصول إلى المعرّف الإعلاني متى كان متاحًا.
بالنسبة إلى التطبيقات التي تستخدم الإصدار 20.3.0 أو الإصدارات الأقدم من حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" وتستهدف نظام التشغيل Android 13، يجب إضافة إذن com.google.android.gms.permission.AD_ID في ملف AndroidManifest.xml لكي تتمكّن حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" من الوصول إلى المعرّف الإعلاني:
لمزيد من المعلومات عن بيان الإذن
com.google.android.gms.permission.AD_ID، بما في ذلك كيفية إيقافه، يمكنك الرجوع إلى مقالة Play
Console هذه.
إعداد حزمة "SDK لإعلانات Google على الأجهزة الجوّالة"
قبل تحميل الإعلانات، عليك إعداد حزمة تطوير البرامج (SDK) لإعلانات Google على الأجهزة الجوّالة من خلال استدعاء MobileAds.initialize().
تُعدّ هذه الطريقة حزمة تطوير البرامج (SDK) وتستدعي أداة معالجة اكتمال بعد اكتمال عملية إعداد كلّ من حزمة تطوير البرامج (SDK) لخدمة "إعلانات Google على الأجهزة الجوّالة" والمحوّل، أو بعد انتهاء المهلة البالغة 30 ثانية. يجب إجراء ذلك مرة واحدة فقط، ويُفضّل عند تشغيل التطبيق.
قد يتم تحميل الإعلانات مسبقًا باستخدام حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" أو حِزم SDK لشركاء التوسّط
عند بدء التشغيل. إذا كنت بحاجة إلى الحصول على موافقة المستخدمين في المنطقة الاقتصادية الأوروبية (EEA)، عليك ضبط أي علامات خاصة بالطلبات، مثل
setTagForChildDirectedTreatment()
أو
setTagForUnderAgeOfConsent()،
أو اتّخاذ إجراءات أخرى قبل تحميل الإعلانات، مع الحرص على تنفيذ ذلك قبل إعداد
حزمة تطوير البرامج (SDK) لإعلانات Google على الأجهزة الجوّالة.
في ما يلي مثال على كيفية استدعاء طريقة initialize() في سلسلة محادثات تعمل في الخلفية ضمن نشاط:
Java
newThread(()->{// Initialize the Google Mobile Ads SDK on a background thread.MobileAds.initialize(this,initializationStatus->{});}).start();
تم الآن استيراد حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" وأنت جاهز لتنفيذ إعلان.
يوفّر AdMob عددًا من أشكال الإعلانات المختلفة، ما يتيح لك اختيار الشكل الأنسب لتجربة المستخدم في تطبيقك.
بانر
تعرض الوحدات الإعلانية لإعلانات البانر إعلانات مستطيلة تشغل جزءًا من تصميم التطبيق. ويمكن تحديثها تلقائيًا بعد فترة زمنية معيّنة. وهذا يعني أنّ المستخدِمين سيشاهدون إعلانًا جديدًا على فترات زمنية منتظمة، حتى إذا ظلّوا على الشاشة نفسها في تطبيقك. ويُعدّ هذا الشكل أبسط أشكال الإعلانات التي يمكن تنفيذها.
تعرض وحدات الإعلانات البينية إعلانات بملء الصفحة داخل تطبيقك. ويمكنك عرض هذه الإعلانات في لحظات التنقّل أو الفواصل التي تحدث بشكلٍ تلقائي في واجهة تطبيقك، على سبيل المثال، بعد اكتمال مستوىً معيّن في أحد تطبيقات الألعاب.
الإعلانات المدمجة مع المحتوى هي إعلانات يمكنك تخصيص طريقة عرض مواد العرض فيها، مثل العناوين وعبارات الحث على اتّخاذ إجراء، في تطبيقاتك. من خلال تصميم الإعلان بنفسك، يمكنك إنشاء عروض إعلانية طبيعية وغير متداخلة يمكن أن تساهم في تقديم تجربة مستخدم غنية.
تتيح وحدات "الإعلانات مقابل مكافأة" للمستخدمين تشغيل الألعاب أو المشاركة في استطلاعات أو مشاهدة فيديوهات للحصول على مكافآت داخل التطبيق، مثل الحصول على عملات معدنية أو محاولات إضافية أو نقاط. يمكنك ضبط مكافآت مختلفة لوحدات إعلانية مختلفة، وتحديد قيم المكافأة والعناصر التي حصل عليها المستخدم.
الإعلان البيني بمكافأة هو نوع جديد من أشكال الإعلانات المحفَّزة التي تتيح لك
تقديم مكافآت، مثل العملات المعدنية أو محاولات إضافية للإعلانات التي تظهر تلقائيًا
أثناء عمليات النقل العادية للتطبيقات.
على عكس الإعلانات مقابل مكافأة، لا يُطلب من المستخدمين الموافقة على عرض إعلان بيني مقابل مكافأة.
وبدلاً من رسالة طلب الموافقة داخل "الإعلانات مقابل مكافأة"، تتطلّب "الإعلانات البينية مقابل مكافأة" شاشة تمهيدية تُعلن عن المكافأة وتمنح المستخدمين فرصة للإيقاف إذا أرادوا إجراء ذلك.
تاريخ التعديل الأخير: 2025-09-02 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-09-02 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\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 Google Mobile Ads SDK into an app is the first step toward displaying ads\nand earning revenue. Once you've integrated the SDK, you can choose an ad\nformat (such as native or rewarded video) and follow the steps to implement 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 Google Mobile Ads SDK to your app-level build file:\n\n Kotlin \n\n ```kotlin\n dependencies {\n implementation(\"com.google.android.gms:play-services-ads:24.5.0\")\n }\n ```\n\n Groovy \n\n ```groovy\n dependencies {\n implementation 'com.google.android.gms:play-services-ads:24.5.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 class=\"readonly\" translate=\"no\"\u003eSAMPLE_APP_ID\u003c/var\u003e\"/\\\u003e\n \u003c/application\u003e\n \u003c/manifest\u003e\n\n Replace \u003cvar class=\"readonly\" 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 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 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 Google Mobile Ads SDK to access the\n 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 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\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 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\nGoogle 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/ccc290a583d7f552bdcf81ea76adc05beaa43f0b/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/ccc290a583d7f552bdcf81ea76adc05beaa43f0b/kotlin/admob/BannerExample/app/src/main/java/com/google/android/gms/example/bannerexample/MainActivity.kt#L167-L176\n\nSelect an ad format\n\nGoogle 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."]]