You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore(flutter): update android section of Amplify Flutter getting started guide (#7760)
* chore: update android section of Flutter getting started guide
* chore: update gen 2 flutter platform setup
* chore: add info to enable network permissions on android
* chore: update H3 headers to H2
* chore: update min Xcode version to 15
* chore: update xcode verison to 15.0 for macOS
* chore: update ios and macos setup to be consistent with Android, add callout for missing podfile
Amplify requires a minimum of API level 24 (Android 7.0), Gradle 7 and Kotlin > 1.9when targeting Android.
1
+
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.
2
2
3
-
_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)._
3
+
<Calloutwarning>
4
+
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.
5
+
</Callout>
4
6
5
-
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:
7
+
1. Open `android/settings.gradle`and update the Android Gradle plugin and kotlin versions:
6
8
7
-
```diff
8
-
plugins {
9
-
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
10
-
- id "com.android.application" version "7.3.0" apply false
11
-
+ id "com.android.application" version "7.4.2" apply false
12
-
id "org.jetbrains.kotlin.android" version "1.9.10" apply false
13
-
}
9
+
```diff title="android/settings.gradle"
10
+
plugins {
11
+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
12
+
- id "com.android.application" version "7.3.0" apply false
13
+
- id "org.jetbrains.kotlin.android" version "1.7.10" apply false
14
+
+ id "com.android.application" version "8.1.0" apply false
15
+
+ id "org.jetbrains.kotlin.android" version "1.9.10" apply false
16
+
}
14
17
```
15
18
16
-
Go to the `android/` directory and open `settings.gradle`. Update the Kotlin plugin version to 1.9.10 or higher:
17
-
18
-
```diff
19
-
plugins {
20
-
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21
-
id "com.android.application" version "7.3.0" apply false
22
-
- id "org.jetbrains.kotlin.android" version "1.7.10" apply false
23
-
+ id "org.jetbrains.kotlin.android" version "1.9.10" apply false
24
-
}
25
-
```
19
+
2. Open `android/gradle/wrapper/gradle-wrapper.properties` and update the Gradle `distributionUrl`.
26
20
27
-
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).
Then, open `android/app/build.gradle`. Update the minimum Android SDK version to 24 or higher:
30
+
3. Open `android/app/build.gradle` and update the Java version and minimum Android SDK version.
31
+
32
+
```diff title="android/app/build.gradle"
33
+
android {
34
+
namespace = "com.example.myapp"
35
+
compileSdk = flutter.compileSdkVersion
36
+
ndkVersion = flutter.ndkVersion
37
+
compileOptions {
38
+
- sourceCompatibility = JavaVersion.VERSION_1_8
39
+
- targetCompatibility = JavaVersion.VERSION_1_8
40
+
+ sourceCompatibility = JavaVersion.VERSION_17
41
+
+ targetCompatibility = JavaVersion.VERSION_17
42
+
}
35
43
36
-
```diff
37
44
defaultConfig {
38
45
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
39
-
applicationId "com.example.myapp"
46
+
applicationId = "com.example.myapp"
40
47
// You can update the following values to match your application needs.
41
48
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
42
-
-minSdkVersion flutter.minSdkVersion
43
-
+minSdkVersion 24
44
-
targetSdkVersion flutter.targetSdkVersion
45
-
versionCode flutterVersionCode.toInteger()
46
-
versionName flutterVersionName
49
+
-minSdk = flutter.minSdkVersion
50
+
+minSdk = 24
51
+
targetSdk = flutter.targetSdkVersion
52
+
versionCode = flutterVersionCode.toInteger()
53
+
versionName = flutterVersionName
47
54
}
55
+
56
+
buildTypes {
57
+
release {
58
+
// TODO: Add your own signing config for the release build.
59
+
// Signing with the debug keys for now, so `flutter run --release` works.
60
+
signingConfig = signingConfigs.debug
61
+
}
62
+
}
63
+
}
64
+
```
65
+
66
+
<Calloutinfo>
67
+
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).
68
+
</Callout>
69
+
70
+
### Network Permissions for Release Builds
71
+
72
+
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.
Copy file name to clipboardExpand all lines: src/fragments/lib/project-setup/flutter/platform-setup/ios.mdx
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
Amplify requires a minimum deployment target of 13.0 and Xcode 13.2 or higher when targeting iOS.
1
+
Amplify requires a minimum deployment target of 13.0 and Xcode 15.0 or higher when targeting iOS.
2
2
3
3
From your project root, navigate to the `ios/` directory and open the `Podfile` in a text editor of your choice. At the top of the file, update the target iOS platform to 13.0 or higher.
Copy file name to clipboardExpand all lines: src/fragments/lib/project-setup/flutter/platform-setup/macos.mdx
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
Amplify requires a minimum deployment target of 10.15 and Xcode 13.2 or higher when targeting macOS. Additionally, you will need to enable networking, keychain entitlements, and code signing.
1
+
Amplify requires a minimum deployment target of 10.15 and Xcode 15.0 or higher when targeting macOS. Additionally, you will need to enable networking, keychain entitlements, and code signing.
@@ -22,38 +22,223 @@ export function getStaticProps(context) {
22
22
}
23
23
24
24
25
-
### iOS
26
-
From your project root, navigate to the `ios/` directory and modify the `Podfile` using a text editor of your choice and update the target iOS platform to 11.0 or higher.
25
+
## iOS
27
26
28
-
```bash
29
-
platform :ios, '11.0'
27
+
Amplify requires a minimum deployment target of 13.0 and Xcode 15.0 or higher when targeting iOS. Follow the steps below to update the minimum deployment target.
28
+
29
+
Open `ios/Podfile` and update the target iOS platform to 13.0 or higher.
30
+
31
+
<Calloutinfo>
32
+
If there is no file located at `ios/Podfile`, add `amplify_flutter` to your `pubspec.yaml` and run `pub get`. This will automatically create the file.
33
+
</Callout>
34
+
35
+
```diff title="ios/Podfile"
36
+
- # Uncomment this line to define a global platform for your project
37
+
- # platform :ios, '12.0'
38
+
+ platform :ios, '13.0'
30
39
```
31
40
32
-
<Callout>
41
+
Open your project in Xcode and select Runner, Targets -> Runner and then the "General" tab. Under the "Minimum Deployments" section, update the iOS version to 13.0 or higher.
42
+
43
+

33
44
34
-
When preparing your application for deployment, you should also update your iOS Deployment Target to at least 11.0. See the [Flutter docs](https://docs.flutter.dev/deployment/ios) to learn more about building your iOS app for release.
45
+
Select Runner, Project -> Runner and then the "Info" tab. Update "iOS Deployment Target" to 13.0 or higher.
35
46
47
+

48
+
49
+
## Android
50
+
51
+
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.
52
+
53
+
<Calloutwarning>
54
+
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.
36
55
</Callout>
37
56
38
-
### Android
39
-
From your project root, navigate to the `android/app/` directory and modify `build.gradle` using a text editor of your choice and update the target Android SDK version to 21 or higher:
57
+
1. Open `android/settings.gradle` and update the Android Gradle plugin and kotlin versions:
40
58
41
-
```bash
42
-
minSdkVersion 21
59
+
```diff title="android/settings.gradle"
60
+
plugins {
61
+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
62
+
- id "com.android.application" version "7.3.0" apply false
63
+
- id "org.jetbrains.kotlin.android" version "1.7.10" apply false
64
+
+ id "com.android.application" version "8.1.0" apply false
65
+
+ id "org.jetbrains.kotlin.android" version "1.9.10" apply false
66
+
}
43
67
```
44
68
45
-
<Calloutwarning>
69
+
2. Open `android/gradle/wrapper/gradle-wrapper.properties` and update the Gradle `distributionUrl`.
46
70
47
-
If you are using Flutter 2.10 or above, you will need to ensure that your app supports an [up-to-date Kotlin version](https://docs.flutter.dev/release/breaking-changes/kotlin-version).
48
-
This will typically be version 1.5.31 or higher.
49
-
<br />
50
-
You can do this by updating the Kotlin version in your app's `android/build.gradle` file:
3. Open `android/app/build.gradle` and update the Java version and minimum Android SDK version.
81
+
82
+
```diff title="android/app/build.gradle"
83
+
android {
84
+
namespace = "com.example.myapp"
85
+
compileSdk = flutter.compileSdkVersion
86
+
ndkVersion = flutter.ndkVersion
87
+
compileOptions {
88
+
- sourceCompatibility = JavaVersion.VERSION_1_8
89
+
- targetCompatibility = JavaVersion.VERSION_1_8
90
+
+ sourceCompatibility = JavaVersion.VERSION_17
91
+
+ targetCompatibility = JavaVersion.VERSION_17
92
+
}
93
+
94
+
defaultConfig {
95
+
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
96
+
applicationId = "com.example.myapp"
97
+
// You can update the following values to match your application needs.
98
+
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
99
+
- minSdk = flutter.minSdkVersion
100
+
+ minSdk = 24
101
+
targetSdk = flutter.targetSdkVersion
102
+
versionCode = flutterVersionCode.toInteger()
103
+
versionName = flutterVersionName
104
+
}
105
+
106
+
buildTypes {
107
+
release {
108
+
// TODO: Add your own signing config for the release build.
109
+
// Signing with the debug keys for now, so `flutter run --release` works.
110
+
signingConfig = signingConfigs.debug
111
+
}
112
+
}
56
113
}
57
114
```
58
115
116
+
<Calloutinfo>
117
+
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).
118
+
</Callout>
119
+
120
+
### Network Permissions for Release Builds
121
+
122
+
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.
There are no Amplify specific requirements or setup instructions when targeting web. You will need to use a browser supported by Flutter. See the following Flutter docs for more info:
-[FAQ: Which web browsers are supported by Flutter?](https://docs.flutter.dev/development/platform-integration/web/faq#which-web-browsers-are-supported-by-flutter)
139
+
140
+
## macOS
141
+
142
+
Amplify requires a minimum deployment target of 10.15 and Xcode 15.0 or higher when targeting macOS. Additionally, you will need to enable networking, keychain entitlements, and code signing.
143
+
144
+
### Update Minimum Version
145
+
146
+
Open `macos/Podfile` and update the target macOS platform to 10.15 or higher.
147
+
148
+
<Calloutinfo>
149
+
If there is no file located at `macos/Podfile`, add `amplify_flutter` to your `pubspec.yaml` and run `pub get`. This will automatically create the file.
59
150
</Callout>
151
+
152
+
```diff title="ios/Podfile"
153
+
- platform :osx, '10.14'
154
+
+ platform :osx, '10.15'
155
+
```
156
+
157
+
Open your project in Xcode and select Runner, Targets -> Runner and then the "General" tab. Under the "Minimum Deployments" section, update the macOS version to 10.15 or higher.
158
+
159
+

160
+
161
+
Select Runner, Project -> Runner and then the "Info" tab. Update "macOS Deployment Target" to 10.15 or higher.
162
+
163
+

164
+
165
+
### Enable Network Calls
166
+
167
+
Open your project in Xcode and select Runner, Targets -> Runner and then the "Signing and Capabilities" tab. Under "App Sandbox" select "Outgoing Connections (Client)".
168
+
169
+

170
+
171
+
For more info on the Networking entitlement, see Apple's documentation on [com.apple.security.network.client](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_network_client).
172
+
173
+
### Enable Keychain Sharing
174
+
175
+
<Calloutinfo>
176
+
177
+
This capability is required because Amplify uses the Data Protection Keychain on macOS as a platform best practice.
178
+
See [TN3137: macOS keychain APIs and implementations](https://developer.apple.com/documentation/technotes/tn3137-on-mac-keychains)
179
+
for more information on how Keychain works on macOS and the Keychain Sharing entitlement.
180
+
181
+
</Callout>
182
+
183
+
Open your project in Xcode and select Runner, Targets -> Runner and then the "Signing and Capabilities" tab.
184
+
185
+
1. Click the "+ icon".
186
+
187
+

188
+
189
+
2. Search for "Keychain Sharing" in the subsequent modal, and add it.
190
+
191
+

192
+
193
+
3. Scroll down to "Keychain Sharing" in the "Signing and Capabilities" and click the "+" icon. By default, your bundle ID will be used.
194
+
195
+

196
+
197
+
4. Finally, add a development team and enable signing.
198
+
199
+

200
+
201
+
202
+
## Windows
203
+
204
+
There are no Amplify specific requirements or setup instructions when targeting Windows. You will need to use a Windows version supported by Flutter. See the following Flutter docs for more info:
Amplify Flutter depends on the [libsecret](https://wiki.gnome.org/Projects/Libsecret) library when targeting Linux.
211
+
212
+
### Local Development
213
+
214
+
To run and debug an app that depends on Amplify Flutter, you must install `libsecret-1-dev`. Run the following commands to install `libsecret-1-dev`. this will also install dependencies of `libsecret-1-dev`, such as `libglib2.0-dev`.
215
+
216
+
<Calloutinfo>
217
+
The command below is intended for Ubuntu. The command may vary on other Linux distributions.
218
+
</Callout>
219
+
220
+
{/* cSpell:disable */}
221
+
222
+
```terminal
223
+
sudo apt-get update
224
+
sudo apt-get install -y libsecret-1-dev
225
+
```
226
+
227
+
{/* cSpell:enable */}
228
+
229
+
### Packaging Your App
230
+
231
+
To include the required dependencies when packaging your app with Snapcraft, include them in your `snapcraft.yaml` file. For more info, see [Flutter's documentation on releasing to the Snap Store](https://docs.flutter.dev/deployment/linux).
0 commit comments