-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update android section of Flutter getting started guide
- Loading branch information
1 parent
2f5f243
commit dfffef5
Showing
3 changed files
with
55 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 52 additions & 32 deletions
84
src/fragments/lib/project-setup/flutter/platform-setup/android.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,68 @@ | ||
Amplify requires a minimum of API level 24 (Android 7.0), Gradle 7 and Kotlin > 1.9 when targeting Android. | ||
Amplify Flutter supports API level 24+ (Android 7.0+), and requires Gradle 8+, Kotlin 1.9+, and Java 17+ when targeting Android. Follow the steps below to apply these changes in your app. | ||
|
||
_If your Flutter app was generated with Flutter 3.16 or lower, please follow the migration guide [here](https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply)._ | ||
<Callout warning> | ||
The steps below are intended for Flutter apps created with Flutter version 3.16+. If your app was created prior to version 3.16, please follow the guide [here](https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply) to migrate to Gradle's declarative plugins block before following the steps below. | ||
</Callout> | ||
|
||
From your project root, navigate to the `android/` directory and open `settings.gradle` in the text editor of your choice. Update the Gradle plugin version to 7.4.2 or higher: | ||
1. Open `android/settings.gradle` and update the Android Gradle plugin and kotlin versions: | ||
|
||
```diff | ||
plugins { | ||
id "dev.flutter.flutter-plugin-loader" version "1.0.0" | ||
- id "com.android.application" version "7.3.0" apply false | ||
+ id "com.android.application" version "7.4.2" apply false | ||
id "org.jetbrains.kotlin.android" version "1.9.10" apply false | ||
} | ||
``` | ||
|
||
Go to the `android/` directory and open `settings.gradle`. Update the Kotlin plugin version to 1.9.10 or higher: | ||
|
||
```diff | ||
plugins { | ||
id "dev.flutter.flutter-plugin-loader" version "1.0.0" | ||
id "com.android.application" version "7.3.0" apply false | ||
- id "org.jetbrains.kotlin.android" version "1.7.10" apply false | ||
+ id "org.jetbrains.kotlin.android" version "1.9.10" apply false | ||
} | ||
```diff title="android/settings.gradle" | ||
plugins { | ||
id "dev.flutter.flutter-plugin-loader" version "1.0.0" | ||
- id "com.android.application" version "7.3.0" apply false | ||
- id "org.jetbrains.kotlin.android" version "1.7.10" apply false | ||
+ id "com.android.application" version "8.1.0" apply false | ||
+ id "org.jetbrains.kotlin.android" version "1.9.10" apply false | ||
} | ||
``` | ||
|
||
Then, open `android/gradle/wrapper/gradle-wrapper.properties`. Update the Gradle `distributionUrl` to a version between 7.3 and 7.6.1 (see the [Flutter docs](https://docs.flutter.dev/release/breaking-changes/android-java-gradle-migration-guide) for more info). | ||
2. Open `android/gradle/wrapper/gradle-wrapper.properties` and update the Gradle `distributionUrl`. | ||
|
||
```diff | ||
```diff title="android/gradle/wrapper/gradle-wrapper.properties" | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip | ||
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip | ||
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip | ||
``` | ||
|
||
Then, open `android/app/build.gradle`. Update the minimum Android SDK version to 24 or higher: | ||
3. Open `android/app/build.gradle` and update the Java version and minimum Android SDK version. | ||
|
||
```diff title="android/app/build.gradle" | ||
android { | ||
namespace = "com.example.myapp" | ||
compileSdk = flutter.compileSdkVersion | ||
ndkVersion = flutter.ndkVersion | ||
compileOptions { | ||
- sourceCompatibility = JavaVersion.VERSION_1_8 | ||
- targetCompatibility = JavaVersion.VERSION_1_8 | ||
+ sourceCompatibility = JavaVersion.VERSION_17 | ||
+ targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
```diff | ||
defaultConfig { | ||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | ||
applicationId "com.example.myapp" | ||
applicationId = "com.example.myapp" | ||
// You can update the following values to match your application needs. | ||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. | ||
- minSdkVersion flutter.minSdkVersion | ||
+ minSdkVersion 24 | ||
targetSdkVersion flutter.targetSdkVersion | ||
versionCode flutterVersionCode.toInteger() | ||
versionName flutterVersionName | ||
- minSdk = flutter.minSdkVersion | ||
+ minSdk = 24 | ||
targetSdk = flutter.targetSdkVersion | ||
versionCode = flutterVersionCode.toInteger() | ||
versionName = flutterVersionName | ||
} | ||
|
||
buildTypes { | ||
release { | ||
// TODO: Add your own signing config for the release build. | ||
// Signing with the debug keys for now, so `flutter run --release` works. | ||
signingConfig = signingConfigs.debug | ||
} | ||
} | ||
} | ||
``` | ||
|
||
<Callout info> | ||
If you would like to use a higher version of Gradle or Android Gradle plugin see the compatibility matrix [here](https://developer.android.com/build/releases/gradle-plugin#updating-gradle). | ||
</Callout> |