コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Android Gradle プラグイン 3.1.0(2018 年 3 月)
このバージョンの 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 は、D8 という新しい DEX コンパイラをデフォルトで使用するようになりました。DEX コンパイルは、.class
バイトコードを Android ランタイム(古いバージョンの Android では Dalvik)用の .dex
バイトコードに変換する処理です。DX という以前のコンパイラと比較すると、D8 はコンパイルが高速で、出力される DEX ファイルのサイズが小さく、しかもアプリのランタイム パフォーマンスは同等以上です。
D8 によって日々のアプリ開発ワークフローが変わることはありませんが、新しいコンパイラに関連する問題が発生した場合は、バグを報告してください。プロジェクトの gradle.properties
ファイルで次のように指定すると、D8 を一時的に無効にして DX を使用できます。
android.enableD8=false
Java 8 言語機能を使用しているプロジェクトの場合、デフォルトで増分 desugar が有効になってます。無効にするには、プロジェクトの gradle.properties
ファイルで次のように指定します。
android.enableIncrementalDesugaring=false.
プレビュー ユーザー: すでに D8 のプレビュー版を使用している場合、JDK ではなく、SDK ビルドツールに含まれるライブラリに対してコンパイルされるようになりました。そのため、JDK には存在するが SDK ビルドツール ライブラリには存在しない API にアクセスすると、コンパイル エラーが発生します。
動作の変更
-
それぞれが異なる ABI をターゲットとする複数の APK をビルドする場合、mips
、mips64
、armeabi
の各 ABI 用の APK がデフォルトで生成されなくなりました。
各 ABI をターゲットとする APK をビルドするには、NDK r16b 以前を使用して、下記のように build.gradle
ファイル内で対象 ABI を指定する必要があります。
splits {
abi {
include 'armeabi', 'mips', 'mips64'
...
}
}
splits {
abi {
include("armeabi", "mips", "mips64")
...
}
}
-
Android プラグインのビルド キャッシュが、30 日以上経過したキャッシュ エントリを削除するようになりました。
-
resConfig
に "auto"
を渡しても、APK にパッケージ化する文字列リソースが自動的に選択されなくなりました。引き続き "auto"
を使用する場合、プラグインはアプリと依存関係で提供されるすべての文字列リソースをパッケージ化します。そのため、プラグインを APK にパッケージ化する各ロケールを指定する必要があります。
-
ローカル モジュールはアプリのテスト APK に依存できないため、androidTestImplementation
の代わりに androidTestApi
コンフィグレーションを使用してインストルメント化テストに依存関係を追加すると、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 がコンポジット ビルドの依存関係を正しく認識しない問題を修正しました。
- 1 回のビルドで Android プラグインを複数回読み込むと(たとえば buildscript のクラスパスに Android プラグインが含まれているサブプロジェクトが複数存在する場合)、プロジェクト同期エラーが発生する問題を修正しました。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-09-03 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-03 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"]]