The Android build system 収集するs app 資源s and source code and 一括s them into APKs or Android App Bundles that you can 実験(する), (軍隊を)展開する,配備する, 調印する, and 分配する.
In Gradle build overview and Android build structure, we discussed build 概念s and the structure of an Android app. Now it's time to configure the build.
Android build glossary
Gradle and the Android Gradle plugin help you configure the に引き続いて 面s of your build:
- Build types
-
Build types define 確かな 所有物/資産/財産s that Gradle uses when building and 一括ing your app. Build types are typically configured for different 行う/開催する/段階s of your 開発 lifecycle.
For example, the debug build type enables debug 選択s and 調印するs the app with the debug 重要な, while the 解放(する) build type may 縮む, obfuscate, and 調印する your app with a 解放(する) 重要な for 配当.
You must define at least one build type to build your app. Android Studio creates the debug and 解放(する) build types by default. To start customizing 一括ing settings for your app, learn how to configure build types.
- 製品 flavors
- 製品 flavors 代表する different 見解/翻訳/版s of your app that you can 解放(する) to 使用者s, such as 解放する/自由な and paid 見解/翻訳/版s. You can customize 製品 flavors to use different code and 資源s while 株ing and 再使用するing the parts that are ありふれた to all 見解/翻訳/版s of your app. 製品 flavors are optional, and you must create them manually. To start creating different 見解/翻訳/版s of your app, learn how to configure 製品 flavors.
- Build variants
- A build variant is a cross-製品 of build type and 製品 flavor and is the configuration Gradle uses to build your app. Using build variants, you can build the debug 見解/翻訳/版 of your 製品 flavors during 開発 and 調印するd 解放(する) 見解/翻訳/版s of your 製品 flavors for 配当. Although you don't configure build variants 直接/まっすぐに, you configure the build types and 製品 flavors that form them. Creating 付加 build types or 製品 flavors also creates 付加 build variants. To learn how to create and manage build variants, read the Configure build variants overview.
- Manifest 入ること/参加(者)s
- You can 明示する values for some 所有物/資産/財産s of the manifest とじ込み/提出する in the build variant configuration. These build values 無視/無効 the 存在するing values in the manifest とじ込み/提出する. This is useful if you want to 生成する 多重の variants of your app with a different 使用/適用 指名する, 最小限 SDK 見解/翻訳/版, or 的 SDK 見解/翻訳/版. When 多重の manifests are 現在の, the manifest 合併 道具 合併するs manifest settings.
- Dependencies
- The build system manages 事業/計画(する) dependencies from your 地元の とじ込み/提出する system and from remote repositories. This means you don't have to manually search, download, and copy binary 一括s of your dependencies into your 事業/計画(する) directory. To find out more, see 追加する build dependencies.
- 調印
- The build system lets you 明示する 調印 settings in the build configuration, and it can automatically 調印する your app during the build 過程. The build system 調印するs the debug 見解/翻訳/版 with a default 重要な and 証明書 using known 信任状 to 避ける a password 誘発する at build time. The build system does not 調印する the 解放(する) 見解/翻訳/版 unless you explicitly define a 調印 configuration for this build. If you don't have a 解放(する) 重要な, you can 生成する one as 述べるd in 調印する your app. 調印するd 解放(する) builds are 要求するd for 分配するing apps through most app 蓄える/店s.
- Code and 資源 縮むing
- The build system lets you 明示する a different ProGuard 支配するs とじ込み/提出する for each build variant. When building your app, the build system 適用するs the appropriate 始める,決める of 支配するs to 縮む your code and 資源s using its built-in 縮むing 道具s, such as R8. 縮むing your code and 資源s can help 減ずる your APK or AAB size.
- 多重の APK support
- The build system lets you automatically build different APKs that each 含む/封じ込める only the code and 資源s needed for a 明確な/細部 審査する 濃度/密度 or 使用/適用 Binary Interface (ABI). For more (警察などへの)密告,告訴(状) see Build 多重の APKs. However, 解放(する)ing a 選び出す/独身 AAB is the recommended approach, as it 申し込む/申し出s splitting by language in 新規加入 to 審査する 濃度/密度 and ABI, while 避けるing the need to upload 多重の artifacts to Google Play. All new apps submitted after August 2021 are 要求するd to use AABs.
Java 見解/翻訳/版s in Android builds
Whether your source code is written in Java, Kotlin, or both, there are several places you must choose a JDK or Java language 見解/翻訳/版 for your build. See Java 見解/翻訳/版s in Android builds for 詳細(に述べる)s.
Build configuration とじ込み/提出するs
Creating custom build configurations 要求するs you to make changes to one or more build configuration とじ込み/提出するs. These plain-text とじ込み/提出するs use a domain-明確な/細部 language (DSL) to 述べる and manipulate the build logic using Kotlin script, which is a flavor of the Kotlin language. You can also use Groovy, which is a dynamic language for the Java 事実上の Machine (JVM), to configure your builds.
You don't need to know Kotlin script or Groovy to start configuring your build because the Android Gradle plugin introduces most of the DSL elements you need. To learn more about the Android Gradle plugin DSL, read the DSL 言及/関連 documentation. Kotlin script also relies on the underlying Gradle Kotlin DSL
When starting a new 事業/計画(する), Android Studio automatically creates some of these とじ込み/提出するs for you and 居住させるs them based on sensible defaults. For an overview of the created とじ込み/提出するs, see Android build structure.
The Gradle Wrapper とじ込み/提出する
The Gradle wrapper (gradlew
) is a small 使用/適用 含むd with your
source code that downloads and 開始する,打ち上げるs Gradle itself.
This creates more-一貫した build 死刑執行. Developers download the
使用/適用 source and run gradlew
. This downloads the 要求するd Gradle
配当, and 開始する,打ち上げるs Gradle to build your 使用/適用.
The gradle/wrapper/gradle-wrapper.所有物/資産/財産s
とじ込み/提出する
含む/封じ込めるs a 所有物/資産/財産, distributionUrl
, that 述べるs which 見解/翻訳/版 of
Gradle is used to run your build.
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/配当s/gradle-8.0-貯蔵所.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
The Gradle settings とじ込み/提出する
The settings.gradle.kts
とじ込み/提出する (for the Kotlin DSL) or
settings.gradle
とじ込み/提出する (for the Groovy DSL) is 位置を示すd in the root
事業/計画(する) directory. This settings とじ込み/提出する defines 事業/計画(する)-level repository
settings and 知らせるs Gradle which modules it should 含む when building your
app. Multi-module 事業/計画(する)s need to 明示する each module that should go into the
final build.
For most 事業/計画(する)s, the とじ込み/提出する looks like the に引き続いて by default:
Kotlin
pluginManagement { /** * The pluginManagement.repositories 封鎖する configures the * repositories Gradle uses to search or download the Gradle plugins and * their transitive dependencies. Gradle pre-configures support for remote * repositories such as JCenter, Maven Central, and Ivy. You can also use * 地元の repositories or define your own remote repositories. Here we * define the Gradle Plugin Portal, Google's Maven repository, * and the Maven Central Repository as the repositories Gradle should use to look for its * dependencies. */ repositories { gradlePluginPortal() google() mavenCentral() } } dependencyResolutionManagement { /** * The dependencyResolutionManagement.repositories * 封鎖する is where you configure the repositories and dependencies used by * all modules in your 事業/計画(する), such as libraries that you are using to * create your 使用/適用. However, you should configure module-明確な/細部 * dependencies in each module-level build.gradle とじ込み/提出する. For new 事業/計画(する)s, * Android Studio 含むs Google's Maven repository and the Maven Central * Repository by default, but it does not configure any dependencies (unless * you select a template that 要求するs some). */ repositoriesMode.始める,決める(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() } } rootProject.指名する = "My 使用/適用" 含む(":app")
Groovy
pluginManagement { /** * The pluginManagement.repositories 封鎖する configures the * repositories Gradle uses to search or download the Gradle plugins and * their transitive dependencies. Gradle pre-configures support for remote * repositories such as JCenter, Maven Central, and Ivy. You can also use * 地元の repositories or define your own remote repositories. Here we * define the Gradle Plugin Portal, Google's Maven repository, * and the Maven Central Repository as the repositories Gradle should use to look for its * dependencies. */ repositories { gradlePluginPortal() google() mavenCentral() } } dependencyResolutionManagement { /** * The dependencyResolutionManagement.repositories * 封鎖する is where you configure the repositories and dependencies used by * all modules in your 事業/計画(する), such as libraries that you are using to * create your 使用/適用. However, you should configure module-明確な/細部 * dependencies in each module-level build.gradle とじ込み/提出する. For new 事業/計画(する)s, * Android Studio 含むs Google's Maven repository and the Maven Central * Repository by default, but it does not configure any dependencies (unless * you select a template that 要求するs some). */ repositoriesMode.始める,決める(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() } } rootProject.指名する = "My 使用/適用" 含む ':app'
The 最高の,を越す-level build とじ込み/提出する
The 最高の,を越す-level build.gradle.kts
とじ込み/提出する (for the Kotlin DSL) or
build.gradle
とじ込み/提出する (for the Groovy DSL) is 位置を示すd in the root
事業/計画(する) directory. It typically defines the ありふれた 見解/翻訳/版s of plugins used
by modules in your 事業/計画(する).
The に引き続いて code 見本 述べるs the default settings and DSL elements in the 最高の,を越す-level build script after creating a new 事業/計画(する):
Kotlin
plugins { /** * Use `適用する 誤った` in the 最高の,を越す-level build.gradle とじ込み/提出する to 追加する a Gradle * plugin as a build dependency but not 適用する it to the 現在の (root) * 事業/計画(する). Don't use `適用する 誤った` in sub-事業/計画(する)s. For more (警察などへの)密告,告訴(状), * see 適用するing 外部の plugins with same 見解/翻訳/版 to subprojects. */ id("com.android.使用/適用") 見解/翻訳/版 "8.10.0" 適用する 誤った id("com.android.library") 見解/翻訳/版 "8.10.0" 適用する 誤った id("org.jetbrains.kotlin.android") 見解/翻訳/版 "2.1.20" 適用する 誤った }
Groovy
plugins { /** * Use `適用する 誤った` in the 最高の,を越す-level build.gradle とじ込み/提出する to 追加する a Gradle * plugin as a build dependency but not 適用する it to the 現在の (root) * 事業/計画(する). Don't use `適用する 誤った` in sub-事業/計画(する)s. For more (警察などへの)密告,告訴(状), * see 適用するing 外部の plugins with same 見解/翻訳/版 to subprojects. */ id 'com.android.使用/適用' 見解/翻訳/版 '8.10.0' 適用する 誤った id 'com.android.library' 見解/翻訳/版 '8.10.0' 適用する 誤った id 'org.jetbrains.kotlin.android' 見解/翻訳/版 '2.1.20' 適用する 誤った }
The module-level build とじ込み/提出する
The module-level build.gradle.kts
(for the Kotlin DSL) or
build.gradle
とじ込み/提出する (for the Groovy DSL) is 位置を示すd in each
事業/計画(する)/module/
directory. It lets you
configure build settings for the 明確な/細部 module it is 位置を示すd in. Configuring
these build settings lets you 供給する custom 一括ing 選択s, such as
付加 build types and 製品 flavors, and 無視/無効 settings in the
main/
app manifest or 最高の,を越す-level build script.
Android SDK Settings
The module-level build とじ込み/提出する for your 使用/適用 含むs settings that 示す Android SDK 見解/翻訳/版s used when 収集するing, selecting 壇・綱領・公約 行為s, and 明示するing the 最小限 見解/翻訳/版 that your 使用/適用 runs on.
-
compileSdk
-
The
compileSdk
決定するs which Android and Java APIs are 利用できる when 収集するing your source code. To use the 最新の Android features, use the 最新の Android SDK when 収集するing.Some Android 壇・綱領・公約 APIs might not be 利用できる in older API levels. You can conditionally guard use of newer features or use AndroidX compatibility libraries to use newer features with lower Android API levels.
Each Android SDK 供給するs a subset of Java APIs for use in your 使用/適用. The (米)棚上げする/(英)提議する at Which Java APIs can I use in my Java or Kotlin source code shows which Java API level is 利用できる based on the Android SDK 見解/翻訳/版. The newer Java APIs are supported on earlier 見解/翻訳/版s of Android through desugaring, which must be enabled in your build.
Android Studio 陳列する,発揮するs 警告s if your
compileSdk
衝突s with the 現在の 見解/翻訳/版 of Android Studio, AGP, or your 事業/計画(する)'s library dependency 必要物/必要条件s. -
minSdk
-
The
minSdk
明示するs the lowest 見解/翻訳/版 of Android that you want your app to support. SettingminSdk
制限するs which 装置s can 任命する/導入する your app.Supporting lower 見解/翻訳/版s of Android might 要求する more 条件付きの checks in your code or more use of AndroidX compatibility libraries. You should 重さを計る the 維持/整備 cost of supporting lower 見解/翻訳/版s against the 百分率 of 使用者s that are still using those lower 見解/翻訳/版s. See the 見解/翻訳/版 chart in the New 事業/計画(する) wizard of Android Studio for the 現在の 見解/翻訳/版-use 百分率s.
When editing your code in Android Studio or running checks during your build, lint will 警告する about APIs that you use that are not 利用できる in the
minSdk
. You should 直す/買収する,八百長をする these by making newer features 条件付きの or by usingAppcompat
for backward compatibility. -
targetSdk
-
The
targetSdk
serves two 目的s:- It 始める,決めるs runtime 行為 of your 使用/適用.
- It attests which 見解/翻訳/版 of Android you've 実験(する)d against.
If you run on a 装置 that's using a higher 見解/翻訳/版 of Android than your
targetSdk
, Android runs your app in a compatibility 方式 that behaves 類似して to the lower 見解/翻訳/版 示すd in yourtargetSdk
. For example, when API 23 introduced the runtime 許可s model, not all apps were ready to すぐに 可決する・採択する it. By settingtargetSdk
to 22, those apps could run on API 23 装置s without using runtime 許可s, and could use features 含むd in the 最新のcompileSdk
見解/翻訳/版. Google Play 配当 政策 施行するs 付加 政策s on 的 API level.The value of
targetSdk
must be いっそう少なく than or equal to that ofcompileSdk
.
公式文書,認める: The values of compileSdk
and targetSdk
don't need to be the same. Keep the に引き続いて basic 原則s in mind:
compileSdk
gives you 接近 to new APIstargetSdk
始める,決めるs the runtime 行為 of your apptargetSdk
must be いっそう少なく than or equal tocompileSdk
見本 app-module build script
This 見本 Android app module build script 輪郭(を描く)s some of the basic DSL elements and settings:
Kotlin
/** * The first section in the build configuration 適用するs the Android Gradle plugin * to this build and makes the android 封鎖する 利用できる to 明示する * Android-明確な/細部 build 選択s. */ plugins { id("com.android.使用/適用") } /** * 位置を示す (and かもしれない download) a JDK used to build your kotlin * source code. This also 行為/法令/行動するs as a default for sourceCompatibility, * targetCompatibility and jvmTarget. 公式文書,認める that this does not 影響する/感情 which JDK * is used to run the Gradle build itself, and does not need to take into * account the JDK 見解/翻訳/版 要求するd by Gradle plugins (such as the * Android Gradle Plugin) */ kotlin { jvmToolchain(11) } /** * The android 封鎖する is where you configure all your Android-明確な/細部 * build 選択s. */ android { /** * The app's namespace. Used まず第一に/本来 to 接近 app 資源s. */ namespace = "com.example.myapp" /** * compileSdk 明示するs the Android API level Gradle should use to * 収集する your app. This means your app can use the API features 含むd in * this API level and lower. */ compileSdk = 33 /** * The defaultConfig 封鎖する encapsulates default settings and 入ること/参加(者)s for all * build variants and can 無視/無効 some せいにするs in main/AndroidManifest.xml * dynamically from the build system. You can configure 製品 flavors to 無視/無効 * these values for different 見解/翻訳/版s of your app. */ defaultConfig { // Uniquely identifies the 一括 for publishing. applicationId = "com.example.myapp" // Defines the 最小限 API level 要求するd to run the app. minSdk = 21 // 明示するs the API level used to 実験(する) the app. targetSdk = 33 // Defines the 見解/翻訳/版 number of your app. versionCode = 1 // Defines a 使用者-friendly 見解/翻訳/版 指名する for your app. versionName = "1.0" } /** * The buildTypes 封鎖する is where you can configure 多重の build types. * By default, the build system defines two build types: debug and 解放(する). The * debug build type is not explicitly shown in the default build configuration, * but it 含むs debugging 道具s and is 調印するd with the debug 重要な. The 解放(する) * build type 適用するs ProGuard settings and is not 調印するd by default. */ buildTypes { /** * By default, Android Studio configures the 解放(する) build type to enable code * 縮むing, using minifyEnabled, and 明示するs the default ProGuard 支配するs とじ込み/提出する. */ getByName("解放(する)") { isMinifyEnabled = true // Enables code 縮むing for the 解放(する) build type. proguardFiles( getDefaultProguardFile("proguard-android.txt"), "proguard-支配するs.プロの/賛成の" ) } } /** * The productFlavors 封鎖する is where you can configure 多重の 製品 flavors. * This lets you create different 見解/翻訳/版s of your app that can * 無視/無効 the defaultConfig 封鎖する with their own settings. 製品 flavors * are optional, and the build system does not create them by default. * * This example creates a 解放する/自由な and paid 製品 flavor. Each 製品 flavor * then 明示するs its own 使用/適用 ID, so that they can 存在する on the Google * Play 蓄える/店 or an Android 装置 同時に. * * If you 宣言する 製品 flavors, you must also 宣言する flavor dimensions * and 割り当てる each flavor to a flavor dimension. */ flavorDimensions += "tier" productFlavors { create("解放する/自由な") { dimension = "tier" applicationId = "com.example.myapp.解放する/自由な" } create("paid") { dimension = "tier" applicationId = "com.example.myapp.paid" } } /** * To 無視/無効 source and 的 compatibility (if different from the * toolchain JDK 見解/翻訳/版), 追加する the に引き続いて. All of these * default to the same value as kotlin.jvmToolchain. If you're using the * same 見解/翻訳/版 for these values and kotlin.jvmToolchain, you can * 除去する these 封鎖するs. */ //compileOptions { // sourceCompatibility = JavaVersion.VERSION_11 // targetCompatibility = JavaVersion.VERSION_11 //} //kotlinOptions { // jvmTarget = "11" //} } /** * The dependencies 封鎖する in the module-level build configuration とじ込み/提出する * 明示するs dependencies 要求するd to build only the module itself. * To learn more, go to 追加する build dependencies. */ dependencies { 実施(事業/計画(する)(":lib")) 実施("androidx.appcompat:appcompat:1.7.1") 実施(fileTree(mapOf("dir" to "libs", "含む" to listOf("*.jar")))) }
Groovy
/** * The first line in the build configuration 適用するs the Android Gradle plugin * to this build and makes the android 封鎖する 利用できる to 明示する * Android-明確な/細部 build 選択s. */ plugins { id 'com.android.使用/適用' } /** * 位置を示す (and かもしれない download) a JDK used to build your kotlin * source code. This also 行為/法令/行動するs as a default for sourceCompatibility, * targetCompatibility and jvmTarget. 公式文書,認める that this does not 影響する/感情 which JDK * is used to run the Gradle build itself, and does not need to take into * account the JDK 見解/翻訳/版 要求するd by Gradle plugins (such as the * Android Gradle Plugin) */ kotlin { jvmToolchain 11 } /** * The android 封鎖する is where you configure all your Android-明確な/細部 * build 選択s. */ android { /** * The app's namespace. Used まず第一に/本来 to 接近 app 資源s. */ namespace 'com.example.myapp' /** * compileSdk 明示するs the Android API level Gradle should use to * 収集する your app. This means your app can use the API features 含むd in * this API level and lower. */ compileSdk 33 /** * The defaultConfig 封鎖する encapsulates default settings and 入ること/参加(者)s for all * build variants and can 無視/無効 some せいにするs in main/AndroidManifest.xml * dynamically from the build system. You can configure 製品 flavors to 無視/無効 * these values for different 見解/翻訳/版s of your app. */ defaultConfig { // Uniquely identifies the 一括 for publishing. applicationId 'com.example.myapp' // Defines the 最小限 API level 要求するd to run the app. minSdk 21 // 明示するs the API level used to 実験(する) the app. targetSdk 33 // Defines the 見解/翻訳/版 number of your app. versionCode 1 // Defines a 使用者-friendly 見解/翻訳/版 指名する for your app. versionName "1.0" } /** * The buildTypes 封鎖する is where you can configure 多重の build types. * By default, the build system defines two build types: debug and 解放(する). The * debug build type is not explicitly shown in the default build configuration, * but it 含むs debugging 道具s and is 調印するd with the debug 重要な. The 解放(する) * build type 適用するs ProGuard settings and is not 調印するd by default. */ buildTypes { /** * By default, Android Studio configures the 解放(する) build type to enable code * 縮むing, using minifyEnabled, and 明示するs the default ProGuard 支配するs とじ込み/提出する. */ 解放(する) { minifyEnabled true // Enables code 縮むing for the 解放(する) build type. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-支配するs.プロの/賛成の' } } /** * The productFlavors 封鎖する is where you can configure 多重の 製品 flavors. * This lets you create different 見解/翻訳/版s of your app that can * 無視/無効 the defaultConfig 封鎖する with their own settings. 製品 flavors * are optional, and the build system does not create them by default. * * This example creates a 解放する/自由な and paid 製品 flavor. Each 製品 flavor * then 明示するs its own 使用/適用 ID, so that they can 存在する on the Google * Play 蓄える/店 or an Android 装置 同時に. * * If you 宣言する 製品 flavors, you must also 宣言する flavor dimensions * and 割り当てる each flavor to a flavor dimension. */ flavorDimensions "tier" productFlavors { 解放する/自由な { dimension "tier" applicationId 'com.example.myapp.解放する/自由な' } paid { dimension "tier" applicationId 'com.example.myapp.paid' } } /** * To 無視/無効 source and 的 compatibility (if different from the * 道具 chain JDK 見解/翻訳/版), 追加する the に引き続いて. All of these * default to the same value as kotlin.jvmToolchain. If you're using the * same 見解/翻訳/版 for these values and kotlin.jvmToolchain, you can * 除去する these 封鎖するs. */ //compileOptions { // sourceCompatibility JavaVersion.VERSION_11 // targetCompatibility JavaVersion.VERSION_11 //} //kotlinOptions { // jvmTarget = '11' //} } /** * The dependencies 封鎖する in the module-level build configuration とじ込み/提出する * 明示するs dependencies 要求するd to build only the module itself. * To learn more, go to 追加する build dependencies. */ dependencies { 実施 事業/計画(する)(":lib") 実施 'androidx.appcompat:appcompat:1.7.1' 実施 fileTree(dir: 'libs', 含む: ['*.jar']) }
Gradle 所有物/資産/財産s とじ込み/提出するs
Gradle also 含むs two 所有物/資産/財産s とじ込み/提出するs, 位置を示すd in your root 事業/計画(する) directory, that you can use to 明示する settings for the Gradle build toolkit itself:
-
gradle.所有物/資産/財産s
- This is where you can configure 事業/計画(する)-wide Gradle settings, such as the Gradle daemon's 最大限 heap size. For more (警察などへの)密告,告訴(状), see Build 環境.
-
地元の.所有物/資産/財産s
-
Configures 地元の 環境 所有物/資産/財産s for the build system, 含むing the
に引き続いて:
ndk.dir
- Path to the NDK. This 所有物/資産/財産 has been deprecated. Any downloaded 見解/翻訳/版s of the NDK are 任命する/導入するd in thendk
directory within the Android SDK directory.sdk.dir
- Path to the Android SDK.cmake.dir
- Path to CMake.ndk.symlinkdir
- In Android Studio 3.5 and higher, creates a symlink to the NDK that can be shorter than the 任命する/導入するd NDK path.
Remap the NDK to a shorter path (Windows only)
In Windows, 道具s in the 任命する/導入するd NDK folder, such as ld.exe
, 結局最後にはーなる with
long paths. The 道具s don't support long paths 井戸/弁護士席.
To create a shorter path, in 地元の.所有物/資産/財産s
, 始める,決める the 所有物/資産/財産
ndk.symlinkdir
to request that the Android Gradle plugin create a symlink to
the NDK. The path of that symlink can be shorter than the 存在するing NDK folder.
For example, ndk.symlinkdir = C:\
results in the に引き続いて symlink:
C:\ndk\19.0.5232133
Sync 事業/計画(する) with Gradle とじ込み/提出するs
When you make changes to the build configuration とじ込み/提出するs in your 事業/計画(する), Android Studio 要求するs that you sync your 事業/計画(する) とじ込み/提出するs so that it can 輸入する your build configuration changes and run some checks to make sure your configuration doesn't create build errors.
To sync your 事業/計画(する) とじ込み/提出するs, click Sync Now in the
notification 妨げる/法廷,弁護士業 that appears when you make a change, as shown in
人物/姿/数字 2, or click Sync 事業/計画(する)
from the menu 妨げる/法廷,弁護士業. If Android Studio finds any errors with your
configuration — for example, your source code uses API features that are only
利用できる in an API level higher than your
compileSdkVersion
— the Messages window 述べるs the 問題/発行する.

Source 始める,決めるs
Android Studio 論理(学)上 groups source code and 資源s for each module
into source 始める,決めるs. When you create a new module, Android Studio
creates a main/
source 始める,決める within the module. A module's
main/
source 始める,決める 含むs the code and 資源s used by all its
build variants.
付加 source 始める,決める directories are optional, and Android
Studio doesn't automatically create them for you when you configure new build
variants. However, creating source 始める,決めるs, 類似の to main/
, helps
組織する とじ込み/提出するs and 資源s that Gradle should only use when building 確かな
見解/翻訳/版s of your app:
-
src/main/
- This source 始める,決める 含むs code and 資源s ありふれた to all build variants.
-
src/buildType/
- Create this source 始める,決める to 含む code and 資源s only for a 明確な/細部 build type.
-
src/productFlavor/
-
Create this source 始める,決める to 含む code and 資源s only for a 明確な/細部
製品 flavor.
公式文書,認める: If you configure your build to 連合させる 多重の 製品 flavors, you can create source 始める,決める directories for each combination of 製品 flavors between the flavor dimensions:
src/productFlavor1ProductFlavor2/
. -
src/productFlavorBuildType/
- Create this source 始める,決める to 含む code and 資源s only for a 明確な/細部 build variant.
For example, to 生成する the "fullDebug" 見解/翻訳/版 of your app, the build system 合併するs code, settings, and 資源s from に引き続いて source 始める,決めるs:
-
src/fullDebug/
(the build variant source 始める,決める) -
src/debug/
(the build type source 始める,決める) -
src/十分な/
(the 製品 flavor source 始める,決める) -
src/main/
(the main source 始める,決める)
公式文書,認める: When you create a new とじ込み/提出する or directory in Android Studio, use the とじ込み/提出する > New menu 選択s to create it for a 明確な/細部 source 始める,決める. The source 始める,決めるs you can choose from are based on your build configurations, and Android Studio automatically creates the 要求するd directories if they don't already 存在する.
If different source 始める,決めるs 含む/封じ込める different 見解/翻訳/版s of the same とじ込み/提出する, Gradle uses the に引き続いて 優先 order when deciding which とじ込み/提出する to use. Source 始める,決めるs on the left 無視/無効 the とじ込み/提出するs and settings of source 始める,決めるs to the 権利:
build variant > build type > 製品 flavor > main source 始める,決める > library dependencies
This 許すs Gradle to use とじ込み/提出するs that are 明確な/細部 to the build variant you are trying to build while 再使用するing activities, 使用/適用 logic, and 資源s that are ありふれた to other 見解/翻訳/版s of your app.
When 合併するing 多重の manifests, Gradle uses the same 優先 order so each build variant can define different 構成要素s or 許可s in the final manifest. To learn more about creating custom source 始める,決めるs, read Create source 始める,決めるs.
見解/翻訳/版 catalogs
If your build 含む/封じ込めるs 多重の modules with ありふれた dependencies, or you have 多重の 独立した・無所属 事業/計画(する)s with ありふれた dependencies, we recommend that you use a 見解/翻訳/版 catalog or 法案 of 構成要素s (BOM) to 明示する the ありふれた 見解/翻訳/版s.
Other build systems
Building Android apps with Bazel is possible but not 公式に supported. Android Studio does not 公式に support Bazel 事業/計画(する)s.
To better understand the 現在の 制限s of building with Bazel, see the known 問題/発行するs.