ベース モジュールの設定
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
App Bundle はデバイスにデプロイできない点で APK とは異なります。1 つのビルド アーティファクト内にアプリのコンパイル済みコードとリソースをすべて含む公開形式です。そのため、署名付き App Bundle をアップロードすると、Google Play がアプリの APK をビルドして署名し、ユーザーに配信するために必要なものがすべて揃います。
始める
ほとんどのアプリ プロジェクトでは、Android App Bundle をサポートするのにそれほど労力はかかりません。Android Studio で新しいアプリ プロジェクトを作成する際に、アプリのベース APK 用のコードとリソースを含むモジュールが標準のアプリ モジュールとしてデフォルトで生成されるからです。つまり、以下の 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")
}
ベース モジュールは、アプリのコア機能を提供するだけでなく、
さらに、ビルド構成やマニフェスト エントリの多くが
影響するためです
ベース モジュールのビルド構成
ほとんどの既存のアプリ プロジェクトでは、ベース モジュールのビルド構成に変更を加える必要はありません。今後 Google Cloud で
機能モジュールをアプリ プロジェクトに追加するか、以前に
ベース モジュールのビルド構成にいくつかの側面があります。
覚えておくべき重要なことがあります。
バージョン コードとアプリのアップデート
Android App Bundle では、Google Play にアップロードする複数の APK のバージョン コードを管理する必要がなくなりました。下記に示すように、アプリのベース モジュールのバージョン コードを 1 つ管理するだけで済みます。
// 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"
}
}
App Bundle をアップロードすると、Google Play がベース モジュール内のバージョン コードを使って、そのバンドルから生成されるすべての APK に同じバージョン コードを割り当てます。それにより、デバイスにアプリがダウンロード、インストールされると、そのアプリの分割 APK はすべて同じバージョン コードを共有します。
新しいコードやリソースを含めてアプリを更新する際は、アプリのベース モジュールのバージョン コードを更新して、新たに App Bundle 全体をビルドする必要があります。その App Bundle を Google Play にアップロードすると、ベース モジュールが指定するバージョン コードに基づいて APK の新しいセットが生成されます。その後で、ユーザーがアプリを更新すると、そのデバイスに現在インストールされているすべての APK の更新版が Google Play から配信されます。それによって、インストールされているすべての APK が新しいバージョン コードに更新されます。
その他の考慮事項
- アプリ署名: ビルドファイルに署名情報を含める場合は、
ベース モジュールのビルド構成ファイルにのみ含めてください。
詳細については、次をご覧ください:
Gradle を設定してアプリに署名します。
- コードの圧縮: アプリ プロジェクト全体で(機能モジュールも含めて)コードの圧縮を有効にする場合は、ベース モジュールの build.gradle ファイルで有効にする必要があります。つまり、機能モジュールにカスタム ProGuard ルールを含めることはできますが、機能モジュールのビルド構成内の
minifyEnabled
プロパティは無視されます。
splits
ブロックは無視される: App Bundle をビルドする際、android.splits
ブロック内のプロパティは Gradle に無視されます。どのタイプの設定 APK を App Bundle がサポートするかを管理したい場合、代わりに android.bundle
を使用して設定 APK のタイプを無効にします。
- アプリのバージョニング: アプリ プロジェクト全体のバージョン コードとバージョン名は、ベース モジュールによって決まります。詳しくは、アプリの更新を管理する方法についての説明をご覧ください。
設定 APK のタイプを無効にするまたは再度有効にする
デフォルトでは、App Bundle をビルドすると、言語リソース、画面密度リソース、ABI ライブラリの各セットの設定 APK の生成がサポートされます。下記に示すように、ベース モジュールの build.gradle
ファイルの android.bundle
ブロックを使用して、設定 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 Library を
詳しくは、追加の言語リソースをダウンロードするをご覧ください。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 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-07-27 UTC。"],[],[],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)"]]