با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
پلاگین Android Gradle 3.1.0 (مارس 2018)
این نسخه از افزونه اندروید به موارد زیر نیاز دارد:
| حداقل نسخه | نسخه پیش فرض | یادداشت ها |
---|
گریدل | 4.4 | 4.4 | برای کسب اطلاعات بیشتر، به روز رسانی Gradle را ببینید. |
ابزارهای ساخت SDK | 27.0.3 | 27.0.3 | ابزارهای ساخت SDK را نصب یا پیکربندی کنید . به خاطر داشته باشید، دیگر نیازی به تعیین نسخه ای برای ابزارهای ساخت با استفاده از ویژگی android.buildToolsVersion ندارید—این افزونه به طور پیش فرض از حداقل نسخه مورد نیاز استفاده می کند. |
کامپایلر جدید DEX، D8
به طور پیش فرض، Android Studio اکنون از یک کامپایلر جدید DEX به نام D8 استفاده می کند. کامپایل DEX فرآیند تبدیل بایت کد .class
به بایت کد .dex
برای زمان اجرا اندروید (یا Dalvik، برای نسخه های قدیمی تر اندروید) است. در مقایسه با کامپایلر قبلی، به نام DX، D8 سریعتر کامپایل میکند و فایلهای DEX کوچکتری را خروجی میدهد، در حالی که عملکرد زمان اجرای برنامه یکسان یا بهتر است.
D8 نباید گردش کار توسعه برنامه روزانه شما را تغییر دهد. با این حال، اگر با مشکلی در ارتباط با کامپایلر جدید مواجه شدید، لطفاً یک اشکال را گزارش کنید . با قرار دادن موارد زیر در فایل gradle.properties
پروژه خود، می توانید D8 را به طور موقت غیرفعال کنید و از DX استفاده کنید:
android.enableD8=false
برای پروژههایی که از ویژگیهای زبان جاوا 8 استفاده میکنند ، قندزدایی افزایشی بهطور پیشفرض فعال است. با مشخص کردن موارد زیر در فایل gradle.properties
پروژه خود می توانید آن را غیرفعال کنید:
android.enableIncrementalDesugaring=false.
کاربران پیشنمایش: اگر قبلاً از نسخه پیشنمایش D8 استفاده میکنید، توجه داشته باشید که اکنون در برابر کتابخانههای موجود در ابزارهای ساخت SDK - نه JDK، کامپایل میشود. بنابراین، اگر به APIهایی دسترسی دارید که در JDK وجود دارند اما در کتابخانههای ابزار ساخت SDK وجود ندارند، با یک خطای کامپایل مواجه میشوید.
تغییر رفتار
هنگام ساخت چندین APK که هر کدام ABI متفاوتی را هدف قرار میدهند، دیگر بهطور پیشفرض APK برای ABIهای زیر تولید نمیکند: mips
، mips64
و armeabi
.
اگر میخواهید APKهایی بسازید که این ABIها را هدف قرار میدهند، باید از NDK r16b یا پایینتر استفاده کنید و ABIها را در فایل build.gradle
خود مشخص کنید، همانطور که در زیر نشان داده شده است:
splits {
abi {
include 'armeabi', 'mips', 'mips64'
...
}
}
splits {
abi {
include("armeabi", "mips", "mips64")
...
}
}
کش ساخت افزونه اندروید اکنون ورودیهای کش قدیمیتر از 30 روز را حذف میکند.
ارسال "auto"
به resConfig
دیگر به طور خودکار منابع رشته ای را برای بسته بندی در APK شما انتخاب نمی کند. اگر به استفاده از "auto"
ادامه دهید، افزونه تمام منابع رشته ای را که برنامه شما و وابستگی های آن ارائه می کند را بسته بندی می کند. بنابراین، در عوض باید هر محلی را که میخواهید افزونه در APK شما بسته بندی کند، مشخص کنید.
از آنجایی که ماژولهای محلی نمیتوانند به APK آزمایشی برنامه شما وابسته باشند، افزودن وابستگیها به تستهای ابزاردار شما با استفاده از پیکربندی androidTestApi
، به جای androidTestImplementation
، باعث میشود Gradle اخطار زیر را صادر کند:
WARNING: Configuration 'androidTestApi' is obsolete
and has been replaced with 'androidTestImplementation'
WARNING: Configuration 'androidTestApi' is obsolete
and has been replaced with 'androidTestImplementation'
رفع می کند
- مشکلی را که در آن Android Studio وابستگیها را در ساختهای ترکیبی به درستی تشخیص نمیدهد، برطرف میکند.
- مشکلی را برطرف میکند که در آن هنگام بارگیری پلاگین Android چندین بار در یک ساخت، با خطای همگامسازی پروژه مواجه میشوید – به عنوان مثال، زمانی که چندین پروژه فرعی هر کدام افزونه Android را در مسیر کلاسی ساختاسکریپ خود قرار میدهند.
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-08-30 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-08-30 بهوقت ساعت هماهنگ جهانی."],[],[],null,["\u003cbr /\u003e\n\nAndroid Gradle Plugin 3.1.0 (March 2018)\n\nThis version of the Android plugin requires the following:\n\n| | Minimum version | Default version | Notes |\n|----------------:|:---------------:|:---------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|\n| Gradle | 4.4 | 4.4 | To learn more, see [updating Gradle](/build/releases/gradle-plugin?buildsystem=ndk-build#updating-gradle). |\n| SDK Build Tools | 27.0.3 | 27.0.3 | [Install](/studio/intro/update#sdk-manager) or [configure](/tools/releases/build-tools) SDK Build Tools. Keep in mind, you no longer need to specify a version for the build tools using the android.buildToolsVersion property---the plugin uses the minimum required version by default. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nNew DEX compiler, D8\n\nBy default, Android Studio now uses a new DEX compiler called D8. DEX\ncompilation is the process of transforming `.class` bytecode into\n`.dex` bytecode for the Android Runtime (or Dalvik, for older\nversions of Android). Compared to the previous compiler, called DX, D8\ncompiles faster and outputs smaller DEX files, all while having the same or\nbetter app runtime performance.\n\nD8 shouldn't change your day-to-day app development workflow. However, if\nyou experience any issues related to the new compiler, please\n[report a bug](/studio/report-bugs). You can temporarily\ndisable D8 and use DX by including the following in your project's\n`gradle.properties` file: \n\n android.enableD8=false\n \nFor projects that\n[use Java 8 language features](/studio/write/java8-support),\nincremental desugaring is enabled by default. You can disable it by\nspecifying the following in your project's `gradle.properties` file: \n\n android.enableIncrementalDesugaring=false.\n \n\n**Preview users:** If you're already using a preview version of D8, note\nthat it now compiles against libraries included in the\n[SDK build tools](/studio/releases/build-tools)---not the JDK.\nSo, if you are accessing APIs that exist in the JDK but not in the SDK build\ntools libraries, you get a compile error.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nBehavior changes\n\n- When building multiple APKs that each target a different ABI, the\n no longer generates APKs for the following ABIs by default:\n `mips`, `mips64`, and `armeabi`.\n\n If you want to build APKs that target these ABIs, you must use\n [NDK r16b or lower](/ndk/downloads/revision_history) and\n specify the ABIs in your `build.gradle` file, as shown below: \n\n ```groovy\n splits {\n abi {\n include 'armeabi', 'mips', 'mips64'\n ...\n }\n }\n \n ``` \n\n ```kotlin\n splits {\n abi {\n include(\"armeabi\", \"mips\", \"mips64\")\n ...\n }\n }\n \n ```\n- The Android plugin's [build\n cache](/studio/build/build-cache) now evicts cache entries that are older than 30 days.\n\n- Passing `\"auto\"` to\n [`resConfig`](https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.ProductFlavor.html#com.android.build.gradle.internal.dsl.ProductFlavor:resConfig(java.lang.String))\n no longer automatically picks string resources to package into your APK.\n If you continue to use `\"auto\"`, the plugin packages all string\n resources your app and its dependencies provide. So, you should instead\n specify each locale that you want the plugin to package into your APK.\n\n- Because local modules can't depend on your app's test APK, adding\n dependencies to your instrumented tests using the\n `androidTestApi` configuration, instead of\n `androidTestImplementation`, causes Gradle to issue the\n following warning:\n\n ```groovy\n WARNING: Configuration 'androidTestApi' is obsolete\n and has been replaced with 'androidTestImplementation'\n \n ``` \n\n ```kotlin\n WARNING: Configuration 'androidTestApi' is obsolete\n and has been replaced with 'androidTestImplementation'\n \n ```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nFixes\n\n- Fixes an issue where Android Studio doesn't properly recognize dependencies in composite builds.\n- Fixes an issue where you get a project sync error when loading the Android plugin multiple times in a single build--for example, when multiple subprojects each include the Android plugin in their buildscript classpath.\n\n\u003cbr /\u003e"]]