Skip to content

Commit d568a7f

Browse files
sfshaza2camsim99
andauthored
Fix(deployment): Improve Android build config docs (#12964)
Fixes #11347. Improves the 'Review the app's build configuration' section in android.md to be more actionable. --------- Co-authored-by: Camille Simon <[email protected]>
1 parent e5feb64 commit d568a7f

File tree

1 file changed

+40
-36
lines changed

1 file changed

+40
-36
lines changed

src/content/deployment/android.md

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -444,36 +444,33 @@ Verify the following values:
444444
[applicationtag]: {{site.android-dev}}/guide/topics/manifest/application-element
445445
[permissiontag]: {{site.android-dev}}/guide/topics/manifest/uses-permission-element
446446

447-
## Review or change the Gradle build configuration {:#review-the-gradle-build-configuration}
447+
## Review the Gradle build configuration {:#review-the-gradle-build-configuration}
448448

449449
To verify the Android build configuration,
450450
review the `android` block in the default
451451
[Gradle build script][gradlebuild].
452452
The default Gradle build script is found at `[project]/android/app/build.gradle.kts`.
453-
You can change the values of any of these properties.
454453

455454
```kotlin title="[project]/android/app/build.gradle.kts"
456455
android {
457456
namespace = "com.example.[project]"
458457
// Any value starting with "flutter." gets its value from
459458
// the Flutter Gradle plugin.
460459
// To change from these defaults, make your changes in this file.
461-
[!compileSdk = flutter.compileSdkVersion!]
460+
compileSdk = flutter.compileSdkVersion
462461
ndkVersion = flutter.ndkVersion
463462

464463
...
465464

466465
defaultConfig {
467466
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
468-
[!applicationId = "com.example.[project]"!]
467+
applicationId = "com.example.[project]"
469468
// You can update the following values to match your application needs.
470-
[!minSdk = flutter.minSdkVersion!]
471-
[!targetSdk = flutter.targetSdkVersion!]
472-
// These two properties use values defined elsewhere in this file.
473-
// You can set these values in the property declaration
474-
// or use a variable.
475-
[!versionCode = flutterVersionCode.toInteger()!]
476-
[!versionName = flutterVersionName!]
469+
// For more information, see: https://flutter.dev/to/review-gradle-config.
470+
minSdk = flutter.minSdkVersion
471+
targetSdk = flutter.targetSdkVersion
472+
versionCode = flutterVersionCode.toInteger()
473+
versionName = flutterVersionName
477474
}
478475

479476
buildTypes {
@@ -484,36 +481,43 @@ android {
484481

485482
[gradlebuild]: {{site.android-dev}}/studio/build/#module-level
486483

487-
### Properties to adjust in build.gradle.kts
484+
### Application ID
488485

489-
| Property | Purpose | Default Value |
490-
|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|
491-
| `compileSdk` | The Android API level against which your app is compiled. This should be the highest version available. If you set this property to `31`, you run your app on a device running API `30` or earlier as long as your app makes uses no APIs specific to `31`. | |
492-
| `defaultConfig` | | |
493-
| `.applicationId` | The final, unique [application ID][] that identifies your app. | |
494-
| `.minSdk` | The [minimum Android API level][] for which you designed your app to run. | `flutter.minSdkVersion` |
495-
| `.targetSdk` | The Android API level against which you tested your app to run. Your app should run on all Android API levels up to this one. | `flutter.targetSdkVersion` |
496-
| `.versionCode` | A positive integer that sets an [internal version number][]. This number only determines which version is more recent than another. Greater numbers indicate more recent versions. App users never see this value. | |
497-
| `.versionName` | A string that your app displays as its version number. Set this property as a raw string or as a reference to a string resource. | |
498-
| `.buildToolsVersion` | The Gradle plugin specifies the default version of the Android build tools that your project uses. To specify a different version of the build tools, change this value. | |
486+
The `applicationId` is the unique identifier for your app on the Google Play Store
487+
and on developers' devices.
499488

500-
{:.table .table-striped}
489+
:::important
490+
Review the `applicationId` in `defaultConfig` and ensure it is unique.
491+
Typically, this is a reverse domain name, such as `com.example.myapp`.
492+
Once you upload your app to the Play Store, you cannot change the Application ID.
493+
:::
501494

502-
To learn more about Gradle, check out the module-level build
503-
section in the [Gradle build file][gradlebuild].
495+
[application-id]: {{site.android-dev}}/studio/build/application-id
504496

505-
:::note
506-
If you use a recent version of the Android SDK,
507-
you might get deprecation warnings about
508-
`compileSdkVersion`, `minSdkVersion`, or `targetSdkVersion`.
509-
You can rename these properties to
510-
`compileSdk`, `minSdk`, and `targetSdk` respectively.
511-
:::
497+
### Android SDK versions
512498

513-
[application ID]: {{site.android-dev}}/studio/build/application-id
514-
[minimum Android API level]: {{site.android-dev}}/studio/publish/versioning#minsdk
515-
[internal version number]: {{site.android-dev}}/studio/publish/versioning
516-
[gradlebuild]: {{site.android-dev}}/studio/build/#module-level
499+
The Flutter tooling sets default values for the Android SDK versions:
500+
501+
* **`compileSdk`**: The version of the Android SDK used to compile the app.
502+
* **`minSdk`**: The minimum Android version that the app supports.
503+
* **`targetSdk`**: The Android version the app is designed and tested to run on.
504+
505+
These default values (`flutter.compileSdkVersion`, etc.) are managed by Flutter
506+
to ensure compatibility with the framework and plugins.
507+
You typically **do not** need to change these unless:
508+
509+
1. **You need a newer API**: If you are using a plugin or feature that requires a higher
510+
`minSdk` than Flutter's default, you can manually set it to a higher version number
511+
(for example, `minSdk = 24`).
512+
2. **You need to lock versions**: If you want to prevent automatic updates to these versions
513+
when upgrading Flutter, you can replace the default variables with specific integer values.
514+
515+
### Version code and name
516+
517+
The `versionCode` and `versionName` are automatically set from your `pubspec.yaml` file
518+
(using the `version: 1.0.0+1` field). You generally don't need to modify these in the Gradle file.
519+
520+
[Version your app]: {{site.android-dev}}/studio/publish/versioning
517521

518522
## Build the app for release
519523

0 commit comments

Comments
 (0)