إعداد الوحدة الأساسية
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تختلف حِزمة التطبيق عن حزمة APK من حيث أنّه لا يمكنك نشر إحداها إلى
الخاص بك. بل إنّه تنسيق نشر يتضمّن جميع بيانات
والموارد البرمجية والموارد في أداة واحدة للإصدار. لذلك، بعد تحميل
حزمة التطبيق الموقعة، فإن Google Play لديها كل ما يحتاج إليه لإنشاء
لملفات APK الخاصة بالتطبيق وعرضها للمستخدمين.
البدء
لن تتطلّب معظم مشاريع التطبيقات الكثير من الجهد للتوافق مع تنسيق "مجموعة حزمات تطبيق Android".
ويرجع ذلك إلى أنّ الوحدة التي تتضمّن رموزًا وموارد لقاعدة تطبيقك
حزمة APK هي وحدة التطبيق العادية التي تحصل عليها تلقائيًا عند
إنشاء مشروع تطبيق جديد في "استوديو Android"
أي أن الوحدة تطبّق المكوّن الإضافي application
المذكور أدناه على
يوفّر ملف build.gradle
الرمز والموارد اللازمة للوظيفة الأساسية.
لتطبيقك.
Groovy
// The standard application plugin creates your app's base module.
plugins {
id 'com.android.application'
}
Kotlin
plugins {
// The standard application plugin creates your app's base module.
id("com.android.application")
}
بالإضافة إلى توفير الوظيفة الأساسية لتطبيقك، تتضمّن الوحدة الأساسية
العديد من إعدادات الإصدار وإدخالات البيان التي
تؤثر في مشروع تطبيقك بالكامل.
إعدادات إنشاء الوحدة الأساسية
بالنسبة إلى معظم مشاريع التطبيقات الحالية، لن تحتاج إلى تغيير أي إجراء في قاعدتك.
تهيئة إنشاء الوحدة. ومع ذلك، إذا كنت تفكر في إضافة
الخاصة بمشروع تطبيقك أو إذا سبق لك إصدار تطبيقك باستخدام
حِزم APK متعددة، فهناك بعض الجوانب في تهيئة إنشاء الوحدة الأساسية
التي يجب وضعها في الاعتبار.
رمز الإصدار وتحديثات التطبيق
باستخدام مجموعات حزمات تطبيق Android، لم تعد مضطرًا لإدارة
رموز الإصدارات لحزم APK متعددة التي تحمّلها إلى Google Play. بدلاً من ذلك،
إدارة رمز إصدار واحد فقط في الوحدة الأساسية من تطبيقك، على النحو الموضّح أدناه:
// In your base module build.gradle file
android {
defaultConfig {
…
// You specify your app’s version code only in the base module.
versionCode 5
versionName "1.0"
}
}
بعد تحميل حِزمة التطبيق، يستخدم Google Play رمز الإصدار الوارد في
أن يتم تعيين رمز الإصدار نفسه لجميع حِزم APK التي تُنشئها منها
تلك الحزمة. أي عندما ينزّل أحد الأجهزة تطبيقك ويثبّته، تقسّم جميع
تتشارك حِزم APK لهذا التطبيق رمز الإصدار نفسه.
عندما تريد تحديث تطبيقك باستخدام رمز أو موارد جديدة، عليك تحديث التطبيق.
رمز الإصدار في الوحدة الأساسية لتطبيقك وإنشاء حزمة تطبيق كاملة جديدة.
وعند تحميل حِزمة التطبيق هذه إلى Google Play، يتم إنشاء مجموعة جديدة من حِزم APK.
بناءً على رمز الإصدار الذي تحدده الوحدة الأساسية. بعد ذلك، عندما
تحديث تطبيقك، فإن Google Play يعرض لهم إصدارات مُحدَّثة من جميع حِزم APK
المثبَّت حاليًا على الجهاز. وهذا يعني أنّه يتم تحديث جميع حِزم APK المثبَّتة إلى
رمز الإصدار الجديد.
اعتبارات أخرى
- توقيع التطبيق: في حال تضمين معلومات التوقيع في ملفات الإصدار،
فيجب عليك فقط تضمينه في ملف إعداد إنشاء الوحدة الأساسية.
لمزيد من المعلومات، يُرجى مراجعة
اضبط Gradle لتوقيع تطبيقك.
- تقليص الرموز: إذا كنت تريد
إتاحة تخفيض عدد الرموز
مشروع التطبيق بأكمله (بما في ذلك وحدات الميزات)، فيجب عليك
ذلك من ملف Build.gradle الخاص بالوحدة الأساسية. أي أنه يمكنك
تضمين قواعد ProGuard المخصصة في وحدة الميزات،
لكن السمة
minifyEnabled
المعروضة
يتم تجاهل عمليات تهيئة إنشاء الوحدة.
- يتم تجاهل مجموعة "
splits
": عند إنشاء حِزمة تطبيق، تعمل أداة Gradle
وتتجاهل الخصائص في الجزء android.splits
. إذا كنت تريد التحكم في
أنواع حِزم APK المتوافقة مع حِزمة تطبيقك، ويمكنك بدلاً من ذلك استخدام
من android.bundle
إلى
إيقاف أنواع حِزم APK للإعداد
- تحديد إصدارات التطبيق: تحدِّد الوحدة الأساسية رمز الإصدار وإصداره.
اسم لمشروع تطبيقك بالكامل. لمزيد من المعلومات، انتقِل إلى القسم
حول كيفية إدارة تحديثات التطبيقات.
إعادة تفعيل أنواع حِزم APK للإعداد أو إيقافها
عندما تنشئ حِزمة تطبيق تلقائيًا، تتيح هذه الحزمة إنشاء إعدادات.
حِزم APK لكل مجموعة من الموارد اللغوية وموارد كثافة الشاشة وواجهة التطبيق الثنائية (ABI)
المكتبات. استخدام كتلة android.bundle
في الوحدة الأساسية
build.gradle
كما هو موضح أدناه، يمكنك إيقاف إتاحة ملف واحد أو أكثر.
أنواع حِزم APK للإعداد:
Groovy
android {
// When building Android App Bundles, the splits block is ignored.
// You can remove it, unless you're going to continue to build multiple
// APKs in parallel with the app bundle
splits {...}
// Instead, use the bundle block to control which types of configuration APKs
// you want your app bundle to support.
bundle {
language {
// This property is set to true by default.
// You can specify `false` to turn off
// generating configuration APKs for language resources.
// These resources are instead packaged with each base and
// feature APK.
// Continue reading below to learn about situations when an app
// might change setting to `false`, otherwise consider leaving
// the default on for more optimized downloads.
enableSplit = false
}
density {
// This property is set to true by default.
enableSplit = true
}
abi {
// This property is set to true by default.
enableSplit = true
}
}
}
Kotlin
android {
// When building Android App Bundles, the splits block is ignored.
// You can remove it, unless you're going to continue to build multiple
// APKs in parallel with the app bundle
splits {...}
// Instead, use the bundle block to control which types of configuration APKs
// you want your app bundle to support.
bundle {
language {
// This property is set to true by default.
// You can specify `false` to turn off
// generating configuration APKs for language resources.
// These resources are instead packaged with each base and
// feature APK.
// Continue reading below to learn about situations when an app
// might change setting to `false`, otherwise consider leaving
// the default on for more optimized downloads.
enableSplit = false
}
density {
// This property is set to true by default.
enableSplit = true
}
abi {
// This property is set to true by default.
enableSplit = true
}
}
}
التعامل مع تغييرات اللغة
يحدّد Google Play موارد اللغة التي يجب تثبيتها باستخدام التطبيق استنادًا إلى
في خيار اللغة ضمن إعدادات جهاز المستخدم ضع في اعتبارك المستخدم الذي
تغيير لغة النظام التلقائية بعد تنزيل تطبيقك.
إذا كان تطبيقك يتيح استخدام هذه اللغة، يطلب الجهاز لغات إضافية وينزّلها.
تهيئة حِزم APK للموارد اللغوية هذه من Google Play.
بالنسبة إلى التطبيقات التي توفّر أداة اختيار اللغة داخل التطبيق وتعمل بشكل ديناميكي
تغيير لغة التطبيق، بغض النظر عن إعدادات اللغة على مستوى النظام
عليك إجراء بعض التغييرات لمنع حدوث أعطال بسبب عدم توفُّر بعض الموارد. أيّ منهما
اضبط السمة android.bundle.language.enableSplit
على false
، أو يمكنك
تنفيذ عمليات تنزيل اللغات عند الطلب باستخدام مكتبة Play Core
هو موضّح في مقالة تنزيل مراجع لغوية إضافية
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-07-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Configure the base module\n\nAn app bundle is different from an APK in that you can't deploy one to a\ndevice. Rather, it's a publishing format that includes all your app's compiled\ncode and resources in a single build artifact. So, after you upload your\nsigned app bundle, Google Play has everything it needs to build and sign your\napp's APKs, and serve them to users.\n\nGet started\n-----------\n\nMost app projects won't require much effort to support Android App Bundles.\nThat's because the module that includes code and resources for your app's base\nAPK is the standard app module, which you get by default when you\n[create a new app project in Android Studio](/studio/projects/create-project).\nThat is, the module that applies the `application` plugin below to its\n`build.gradle` file provides the code and resources for the base functionality\nof your app. \n\n### Groovy\n\n```groovy\n// The standard application plugin creates your app's base module.\nplugins {\n id 'com.android.application'\n}\n```\n\n### Kotlin\n\n```kotlin\nplugins {\n // The standard application plugin creates your app's base module.\n id(\"com.android.application\")\n}\n```\n\nIn addition to providing the core functionality for your app, the base module\nalso provides many of the build configurations and manifest entries that\naffect your entire app project.\n\nThe base module build configuration\n-----------------------------------\n\nFor most existing app projects, you don't need to change anything in your base\nmodule's build configuration. However, if you are considering adding\nfeature modules to your app project or if you previously released your app using\nmultiple APKs, there are some aspects to the base module's build configuration\nthat you should keep in mind.\n\n### Version code and app updates\n\nWith Android App Bundles, you no longer have to manage\nversion codes for multiple APKs that you upload to Google Play. Instead, you\nmanage only one version code in the base module of your app, as shown below: \n\n // In your base module build.gradle file\n android {\n defaultConfig {\n ...\n // You specify your app's version code only in the base module.\n versionCode 5\n versionName \"1.0\"\n }\n }\n\nAfter you upload your app bundle, Google Play uses the version code in your\nbase module to assign the same version code to all the APKs it generates from\nthat bundle. That is, when a device downloads and installs your app, all split\nAPKs for that app share the same version code.\n\nWhen you want to update your app with new code or resources, you must update\nthe version code in your app's base module, and build a new, full app bundle.\nWhen you upload that app bundle to Google Play, it generates a new set of APKs\nbased on the version code the base module specifies. Subsequently, when users\nupdate your app, Google Play serves them updated versions of all APKs\ncurrently installed on the device. That is, all installed APKs are updated to\nthe new version code.\n\n### Other considerations\n\n- **App signing:** If you include signing information in your build files, you should only include it in the base module's build configuration file. For more information, see [Configure Gradle to sign your app](/studio/publish/app-signing#gradle-sign).\n- **Code shrinking:** If you want to [enable code shrinking](/studio/build/shrink-code#shrink-code) for your entire app project (including its feature modules), you must do so from the base module's build.gradle file. That is, you can include custom ProGuard rules in a feature module, but the `minifyEnabled` property in feature module build configurations is ignored.\n- **The `splits` block is ignored:** When building an app bundle, Gradle ignores properties in the `android.splits` block. If you want to control which types of configuration APKs your app bundle supports, instead use `android.bundle` to [disable types of configuration APKs](#disable_config_apks).\n- **App versioning:** The base module determines the version code and version name for your entire app project. For more information, go to the section about how to [Manage app updates](#manage_app_updates).\n\n### Re-enable or disable types of configuration APKs\n\nBy default, when you build an app bundle, it supports generating configuration\nAPKs for each set of language resources, screen density resources, and ABI\nlibraries. Using the `android.bundle` block in your base module's\n`build.gradle` file, as shown below, you can disable support for one or more\ntypes of configuration APKs: \n\n### Groovy\n\n```groovy\nandroid {\n // When building Android App Bundles, the splits block is ignored.\n // You can remove it, unless you're going to continue to build multiple\n // APKs in parallel with the app bundle\n splits {...}\n\n // Instead, use the bundle block to control which types of configuration APKs\n // you want your app bundle to support.\n bundle {\n language {\n // This property is set to true by default.\n // You can specify `false` to turn off\n // generating configuration APKs for language resources.\n // These resources are instead packaged with each base and\n // feature APK.\n // Continue reading below to learn about situations when an app\n // might change setting to `false`, otherwise consider leaving\n // the default on for more optimized downloads.\n enableSplit = false\n }\n density {\n // This property is set to true by default.\n enableSplit = true\n }\n abi {\n // This property is set to true by default.\n enableSplit = true\n }\n }\n}\n```\n\n### Kotlin\n\n```kotlin\nandroid {\n // When building Android App Bundles, the splits block is ignored.\n // You can remove it, unless you're going to continue to build multiple\n // APKs in parallel with the app bundle\n splits {...}\n\n // Instead, use the bundle block to control which types of configuration APKs\n // you want your app bundle to support.\n bundle {\n language {\n // This property is set to true by default.\n // You can specify `false` to turn off\n // generating configuration APKs for language resources.\n // These resources are instead packaged with each base and\n // feature APK.\n // Continue reading below to learn about situations when an app\n // might change setting to `false`, otherwise consider leaving\n // the default on for more optimized downloads.\n enableSplit = false\n }\n density {\n // This property is set to true by default.\n enableSplit = true\n }\n abi {\n // This property is set to true by default.\n enableSplit = true\n }\n }\n}\n```\n\n### Handling language changes\n\nGoogle Play determines which language resources to install with the app based\non the language selection in the user's device settings. Consider a user who\nchanges their default system language after already downloading your app.\nIf your app supports that language, the device requests and downloads additional\nconfiguration APKs for those language resources from Google Play.\n\nFor apps that offer a language picker inside the application and dynamically\nchange the app's language, independent of the system level language setting,\nyou must make some changes to prevent crashes due to missing resources. Either\nset the `android.bundle.language.enableSplit` property to `false`, or consider\nimplementing on-demand language downloads using the Play Core library as\ndescribed in [Download additional language resources](/guide/playcore/feature-delivery/on-demand#lang_resources)"]]