קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
Android Gradle Plugin 3.1.0 (מרץ 2018)
כדי להשתמש בגרסה הזו של הפלאגין ל-Android, צריך:
|
גרסת מינימום |
גרסת ברירת המחדל |
הערות |
Gradle |
4.4 |
4.4 |
יש מידע נוסף במאמר בנושא עדכון Gradle. |
SDK Build Tools |
27.0.3 |
27.0.3 |
התקנה או הגדרה של SDK Build Tools. חשוב לזכור: כבר לא צריך לציין גרסה לכלי הבנייה באמצעות המאפיין android.buildToolsVersion – הפלאגין משתמש בגרסה המינימלית הנדרשת כברירת מחדל. |
מהדר DEX חדש, D8
כברירת מחדל, Android Studio משתמש עכשיו במהדר DEX חדש שנקרא D8. הידור DEX הוא תהליך של המרת קוד בייט .class
לקוד בייט .dex
עבור זמן הריצה של Android (או Dalvik, בגרסאות ישנות יותר של Android). בהשוואה לקומפיילר הקודם, שנקרא DX, קומפיילר D8 מבצע קומפילציה מהר יותר ומפיק קובצי DEX קטנים יותר, וכל זאת תוך שמירה על ביצועים זהים או טובים יותר של זמן הריצה של האפליקציה.
השימוש ב-D8 לא אמור לשנות את תהליך העבודה היומיומי של פיתוח האפליקציה. עם זאת, אם נתקלים בבעיות שקשורות לקומפיילר החדש, אפשר לדווח על באג. אפשר להשבית את D8 באופן זמני ולהשתמש ב-DX על ידי הוספת השורה הבאה לקובץ gradle.properties
של הפרויקט:
android.enableD8=false
בפרויקטים שבהם נעשה שימוש בתכונות של שפת Java 8, ההגדרה של ביטול הסוכר המצטבר מופעלת כברירת מחדל. כדי להשבית את התכונה, צריך לציין את הערך הבא בקובץ gradle.properties
של הפרויקט:
android.enableIncrementalDesugaring=false.
משתמשי גרסת טרום-השקה: אם אתם כבר משתמשים בגרסת טרום-השקה של D8, שימו לב שעכשיו היא מתבצעת קומפילציה מול ספריות שכלולות בכלי ה-build של SDK, ולא מול JDK.
לכן, אם ניגשים לממשקי API שקיימים ב-JDK אבל לא בספריות של כלי ה-build של ה-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")
...
}
}
-
התוסף ל-Android build
cache מסיר עכשיו רשומות במטמון שנוצרו לפני יותר מ-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 לא מזהה כראוי תלויות ב-composite builds.
- תוקנה בעיה שגורמת לשגיאה בסנכרון הפרויקט כשמעמיסים את הפלאגין של Android כמה פעמים בגרסה אחת – לדוגמה, כשכמה פרויקטים משניים כוללים את הפלאגין של Android בנתיב המחלקות של סקריפט הבנייה שלהם.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-09-05 (שעון UTC).
[[["התוכן קל להבנה","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-05 (שעון UTC)."],[],[],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"]]