-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(flutter): update android section of Amplify Flutter getting started guide #7760
Merged
Jordan-Nelson
merged 7 commits into
aws-amplify:main
from
Jordan-Nelson:chore/flutter-android-setup
Jun 21, 2024
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a8954ad
chore: update android section of Flutter getting started guide
Jordan-Nelson c64f758
chore: update gen 2 flutter platform setup
Jordan-Nelson d6f72be
chore: add info to enable network permissions on android
Jordan-Nelson a8a82be
chore: update H3 headers to H2
Jordan-Nelson 93b220c
chore: update min Xcode version to 15
Jordan-Nelson 049dc17
chore: update xcode verison to 15.0 for macOS
Jordan-Nelson 10072a3
chore: update ios and macos setup to be consistent with Android, add …
Jordan-Nelson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
97 changes: 65 additions & 32 deletions
97
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,81 @@ | ||
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 | ||
} | ||
```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 | ||
} | ||
``` | ||
|
||
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 | ||
} | ||
``` | ||
2. Open `android/gradle/wrapper/gradle-wrapper.properties` and update the Gradle `distributionUrl`. | ||
|
||
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). | ||
|
||
```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> | ||
|
||
### Network Permissions for Release Builds | ||
|
||
Flutter apps have access to make network requests by default in debug mode. This permission needs to be added when building in release mode. To do this, open `android/app/src/main/AndroidManifest.xml` and make the following addition. | ||
|
||
```xml title="android/app/src/main/AndroidManifest.xml" | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
// highlight-start | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
// highlight-end | ||
... | ||
</manifest> | ||
``` |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Should this be 8.1.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the removed code. Diff might look confusing since this is a diff of a diff