با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
ماژول های ویژگی به شما این امکان را می دهند که ویژگی ها و منابع خاصی را از ماژول پایه برنامه خود جدا کرده و در بسته نرم افزاری خود قرار دهید. سپس میتوانید گزینههای تحویل را سفارشی کنید تا کنترل کنید دستگاههای دارای Android 5.0 (سطح API 21) یا بالاتر، چه زمانی و چگونه ویژگیهای برنامه شما را دانلود کنند.
به خاطر داشته باشید، این نوع ماژولارسازی به تلاش بیشتری نیاز دارد و احتمالاً کدهای موجود برنامه شما را تغییر میدهد، بنابراین به دقت در نظر بگیرید که کدام یک از ویژگیهای برنامه شما از در دسترس قرار گرفتن کاربران در صورت تقاضا بیشترین سود را خواهد داشت.
اگر میخواهید به تدریج ویژگیهای برنامه را در طول زمان مدولار کنید، بدون تغییر رفتار برنامه یا سفارشی کردن گزینههای تحویل پیشرفته، میتوانید این کار را با ایجاد ماژولهای ویژگی که برای تحویل در زمان نصب پیکربندی شدهاند انجام دهید. یعنی میتوانید یک ویژگی را بهعنوان ماژول ویژگی مدولار کنید، اما گزینههای پیشرفته را فعال نکنید تا زمانی که کاربر برنامه شما را نصب میکند، این ویژگی در دسترس باشد.
علاوه بر این، ماژول های ویژگی که برای تحویل در زمان نصب پیکربندی شده اند، این گزینه را دارند که در صورت عدم نیاز، بعداً حذف نصب شوند. برای آن، آنها باید به عنوان قابل جابجایی تنظیم شوند.
این بخش نحوه ایجاد یک ماژول ویژگی برای تحویل در زمان نصب را توضیح می دهد. قبل از شروع، مطمئن شوید که از Android Studio نسخه 3.5 یا بالاتر و Android Gradle Plugin نسخه 3.5.0 یا بالاتر استفاده می کنید.
یک ماژول جدید برای تحویل در زمان نصب پیکربندی کنید
ساده ترین راه برای ایجاد یک ماژول ویژگی جدید استفاده از Android Studio 3.5 یا بالاتر است. از آنجایی که ماژول های ویژگی وابستگی ذاتی به ماژول برنامه پایه دارند، می توانید آنها را فقط به پروژه های برنامه موجود اضافه کنید.
برای افزودن یک ماژول ویژگی به پروژه برنامه خود با استفاده از Android Studio، به صورت زیر عمل کنید:
اگر قبلاً این کار را نکرده اید، پروژه برنامه خود را در IDE باز کنید.
File > New > New Module را از نوار منو انتخاب کنید.
در گفتگوی Create New Module ، Dynamic Feature Module را انتخاب کرده و روی Next کلیک کنید.
در قسمت Configure your new module موارد زیر را تکمیل کنید:
ماژول برنامه کاربردی پایه را برای پروژه برنامه خود از منوی کشویی انتخاب کنید.
نام ماژول را مشخص کنید. IDE از این نام برای شناسایی ماژول به عنوان یک پروژه فرعی Gradle در فایل تنظیمات Gradle شما استفاده می کند. هنگامی که بسته برنامه خود را می سازید، Gradle از آخرین عنصر نام پروژه فرعی برای تزریق ویژگی <manifest split> در مانیفست ماژول ویژگی استفاده می کند.
نام بسته ماژول را مشخص کنید. به طور پیشفرض، اندروید استودیو نام بستهای را پیشنهاد میکند که نام بسته ریشه ماژول پایه و نام ماژولی را که در مرحله قبل مشخص کردهاید ترکیب میکند.
حداقل سطح API را که می خواهید ماژول از آن پشتیبانی کند، انتخاب کنید. این مقدار باید با ماژول پایه مطابقت داشته باشد.
روی Next کلیک کنید.
در قسمت گزینه های دانلود ماژول موارد زیر را تکمیل کنید:
عنوان ماژول را با حداکثر 50 کاراکتر مشخص کنید. ماژول پایه برنامه شما باید عنوان ماژول را به عنوان منبع رشته ای داشته باشد که می توانید آن را ترجمه کنید. هنگام ایجاد ماژول با استفاده از Android Studio، IDE منبع رشته را به ماژول پایه برای شما اضافه می کند و ورودی زیر را در مانیفست ماژول ویژگی تزریق می کند:
در منوی کشویی زیر Install-time inclusion ، Include module at the install-time را انتخاب کنید. Android Studio موارد زیر را در مانیفست ماژول تزریق می کند تا انتخاب شما را منعکس کند:
اگر میخواهید یاد بگیرید که چگونه یک ماژول ویژگی ایجاد کنید که بتوانید پس از نصب برنامه دانلود کنید، پیکربندی تحویل درخواستی را بخوانید.
اگر میخواهید این ماژول برای دستگاههای دارای Android 4.4 (سطح API 20) و پایینتر در دسترس باشد و در چند APK گنجانده شود، کادر کنار Fusing را علامت بزنید. یعنی میتوانید آن را از دستگاههایی که از دانلود و نصب فایلهای APK تقسیمشده پشتیبانی نمیکنند حذف کنید. Android Studio موارد زیر را در مانیفست ماژول تزریق می کند تا انتخاب شما را منعکس کند:
پس از اتمام ساخت ماژول اندروید استودیو، محتویات آن را خودتان از پنجره Project بررسی کنید ( مشاهده > ابزار ویندوز > پروژه را از نوار منو انتخاب کنید). کد، منابع و سازمان پیشفرض باید مشابه ماژول برنامه استاندارد باشد.
ماژول زمان نصب را قابل جابجایی کنید
ممکن است ایجاد ماژولهای ویژگی برای تحویل در زمان نصب مفید باشد که در صورت عدم نیاز، این گزینه را دارند که بعداً حذف نصب شوند. برای مثال، برای کاهش اندازه نصبشده برنامهتان، میتوانید محتوایی را که برای آموزش یا نصب نیاز است مدولار کنید و پس از اینکه کاربر برای استفاده از برنامه شما تنظیم شد ، ماژول ویژگی را با استفاده از Play Core API حذف نصب کنید .
ماژول های زمان نصب به طور پیش فرض قابل جابجایی نیستند. برای علامتگذاری یک ماژول بهعنوان قابل جابجایی و اجازه حذف نصب، تگ removable را اضافه کنید و مقدار آن را روی true تنظیم کنید:
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Configure install-time delivery\n\nFeature modules allow you to separate certain features and resources\nfrom the base module of your app and include them in your app bundle. You can\nthen [customize delivery options](/guide/playcore/feature-delivery#customize_delivery)\nto control when and how devices running Android 5.0 (API level 21) or higher\ndownload your app's features.\n\nKeep in mind, this type of modularization requires more effort and possibly\nrefactoring your app's existing code, so consider carefully which of your\napp's features would benefit the most from being available to users on demand.\n\nIf you want to gradually modularize app features over time, without\nchanging the behavior of your app or customizing advanced delivery options, you\ncan do so by creating feature modules that are configured for install-time\ndelivery. That is, you can modularize a feature as a feature module, but not\nenable advanced options so the feature is available when a user installs your\napp.\n\nAdditionally, feature modules that are configured for install-time delivery have the option to later be uninstalled if they're no longer required. For that, they need to be [set up as removable](#make-removable).\n\nThis section describes how to create a feature module for install-time\ndelivery. Before you begin, make sure you're\nusing [Android Studio 3.5](/studio) or higher and Android Gradle Plugin 3.5.0\nor higher.\n\nConfigure a new module for install-time delivery\n------------------------------------------------\n\nThe easiest way to create a new feature module is by using\n[Android Studio 3.5](/studio) or higher.\nBecause feature modules have an\ninherent dependency on the base app module, you can add them only to existing\napp projects.\n\nTo add a feature module to your app project using Android Studio,\nproceed as follows:\n\n1. If you haven't already done so, open your app project in the IDE.\n2. Select **File \\\u003e New \\\u003e New Module** from the menu bar.\n3. In the **Create New Module** dialog, select **Dynamic Feature Module** and click **Next**.\n4. In the **Configure your new module** section, complete the following:\n 1. Select the **Base application module** for your app project from the dropdown menu.\n 2. Specify a **Module name** . The IDE uses this name to identify the module as a Gradle subproject in your [Gradle settings file](/studio/build#settings-file). When you build your app bundle, Gradle uses the last element of the subproject name to inject the `\u003cmanifest split\u003e` attribute in the [feature module's manifest](/guide/app-bundle/dynamic-delivery#dynamic_feature_manifest).\n 3. Specify the module's **package name**. By default, Android Studio suggests a package name that combines the root package name of the base module and the module name you specified in the previous step.\n 4. Select the **Minimum API level** you want the module to support. This value should match that of the base module.\n5. Click **Next**.\n6. In the **Module Download Options** section, complete the following:\n\n 1. Specify the **Module title** using up to 50 characters. Your app's base\n module must include the module title as a\n [string resource](/guide/topics/resources/string-resource), which you\n can translate. When creating the module using Android Studio, the IDE\n adds the string resource to the base module for you and injects the\n following entry in the feature module's manifest:\n\n \u003cdist:module\n ...\n dist:title=\"@string/feature_title\"\u003e\n \u003c/dist:module\u003e\n\n | **Note:** If you enable resource shrinking, such as for your release builds, the shrinker might remove the module title string resource if code in your base module does not reference it. To make sure the string resource remains in the build output, include the resource in a [custom resource keep file](/studio/build/shrink-code#keep-resources).\n 2. In the dropdown menu under **Install-time inclusion** , select **Include\n module at install-time**. Android Studio injects the following in the\n module's manifest to reflect your choice:\n\n \u003cdist:module ... \u003e\n \u003cdist:delivery\u003e\n \u003cdist:install-time /\u003e\n \u003c/dist:delivery\u003e\n \u003c/dist:module\u003e\n\n If you want to learn how to create a feature module\n that you can download after app install, read\n [configure on-demand delivery](/studio/projects/dynamic-delivery/on-demand-delivery).\n 3. Check the box next to **Fusing** if you want this module to be available\n to devices running Android 4.4 (API level 20) and lower and included in\n multi-APKs. That means you can omit it from devices that don't support\n downloading and installing split APKs. Android Studio injects the\n following in the module's manifest to reflect your choice:\n\n \u003cdist:module ...\u003e\n \u003cdist:fusing dist:include=\"true | false\" /\u003e\n \u003c/dist:module\u003e\n\n7. Click **Finish**.\n\nAfter Android Studio finishes creating your module, inspect its contents\nyourself from the **Project** pane (select **View \\\u003e Tool Windows \\\u003e Project**\nfrom the menu bar). The default code, resources, and organization should be\nsimilar to those of the standard app module.\n\nMake an install-time module removable\n-------------------------------------\n\nIt might be useful to create feature modules for install-time delivery that have the option to be later uninstalled if no longer required. For example, to reduce the installed size of\nyour app, you can modularize content that's required for training or onboarding,\nand then\n[uninstall the feature module](/guide/playcore/feature-delivery/on-demand#uninstall_modules) using the Play Core API\nafter the user is set up to use your app.\n\nInstall-time modules are not removable by default. To mark a module as removable and allow it to be uninstalled, add the `removable` tag and set its value to `true`: \n\n \u003cdist:module ... \u003e\n \u003cdist:delivery\u003e\n \u003cdist:install-time\u003e\n \u003cdist:removable dist:value=\"true\"/\u003e\n \u003c/dist:install-time\u003e\n \u003c/dist:delivery\u003e\n \u003c/dist:module\u003e\n\n| **Note:** Configuring too many install-time modules as removable might increase the download and install time for your app. To avoid this issue, keep the number of removable install-time delivery modules under 10."]]