Skip to content

Commit b771cf9

Browse files
Fix(docs): Add Groovy syntax tabs to Android deployment guide (fixes #12793) (#12863)
Resolves #12793 by adding Tabs to 'deployment/android.md' that provide Groovy syntax examples alongside the existing Kotlin (KTS) examples. This ensures users with older Flutter projects or those preferring Groovy can follow the Material dependency, Keystore, and Signing configuration steps. --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 230b57c commit b771cf9

File tree

1 file changed

+128
-49
lines changed

1 file changed

+128
-49
lines changed

src/content/deployment/android.md

Lines changed: 128 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,30 @@ For example:
7575

7676
1. Add the dependency on Android's Material in `<my-app>/android/app/build.gradle.kts`:
7777

78-
```groovy
79-
dependencies {
80-
// ...
81-
implementation("com.google.android.material:material:<version>")
82-
// ...
83-
}
84-
```
78+
<Tabs key="android-material-dependency">
79+
<Tab name="Kotlin">
80+
81+
```kotlin
82+
dependencies {
83+
// ...
84+
implementation("com.google.android.material:material:<version>")
85+
// ...
86+
}
87+
```
88+
89+
</Tab>
90+
<Tab name="Groovy">
91+
92+
```groovy
93+
dependencies {
94+
// ...
95+
implementation 'com.google.android.material:material:<version>'
96+
// ...
97+
}
98+
```
99+
100+
</Tab>
101+
</Tabs>
85102

86103
To find out the latest version, visit [Google Maven][maven-material].
87104

@@ -207,52 +224,114 @@ To configure Gradle, edit the `<project>/android/app/build.gradle.kts` file.
207224

208225
1. Set the `keystoreProperties` object to load the `key.properties` file.
209226

210-
```kotlin diff title="[project]/android/app/build.gradle.kts"
211-
+ import java.util.Properties
212-
+ import java.io.FileInputStream
213-
+
214-
plugins {
215-
...
216-
}
217-
+
218-
+ val keystoreProperties = Properties()
219-
+ val keystorePropertiesFile = rootProject.file("key.properties")
220-
+ if (keystorePropertiesFile.exists()) {
221-
+ keystoreProperties.load(FileInputStream(keystorePropertiesFile))
222-
+ }
223-
+
224-
android {
225-
...
226-
}
227-
```
227+
<Tabs key="android-keystore-properties">
228+
<Tab name="Kotlin">
229+
230+
```kotlin diff title="[project]/android/app/build.gradle.kts"
231+
+ import java.util.Properties
232+
+ import java.io.FileInputStream
233+
+
234+
plugins {
235+
...
236+
}
237+
+
238+
+ val keystoreProperties = Properties()
239+
+ val keystorePropertiesFile = rootProject.file("key.properties")
240+
+ if (keystorePropertiesFile.exists()) {
241+
+ keystoreProperties.load(FileInputStream(keystorePropertiesFile))
242+
+ }
243+
+
244+
android {
245+
...
246+
}
247+
```
248+
249+
</Tab>
250+
<Tab name="Groovy">
251+
252+
```groovy diff title="[project]/android/app/build.gradle"
253+
+ import java.util.Properties
254+
+ import java.io.FileInputStream
255+
+
256+
plugins {
257+
...
258+
}
259+
+
260+
+ def keystoreProperties = new Properties()
261+
+ def keystorePropertiesFile = rootProject.file('key.properties')
262+
+ if (keystorePropertiesFile.exists()) {
263+
+ keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
264+
+ }
265+
+
266+
android {
267+
...
268+
}
269+
```
270+
271+
</Tab>
272+
</Tabs>
228273

229274
1. Add the signing configuration before the `buildTypes` property block
230275
inside the `android` property block.
231276

232-
```kotlin diff title="[project]/android/app/build.gradle.kts"
233-
android {
234-
// ...
235-
236-
+ signingConfigs {
237-
+ create("release") {
238-
+ keyAlias = keystoreProperties["keyAlias"] as String
239-
+ keyPassword = keystoreProperties["keyPassword"] as String
240-
+ storeFile = keystoreProperties["storeFile"]?.let { file(it) }
241-
+ storePassword = keystoreProperties["storePassword"] as String
242-
+ }
243-
+ }
244-
buildTypes {
245-
release {
246-
// TODO: Add your own signing config for the release build.
247-
// Signing with the debug keys for now,
248-
// so `flutter run --release` works.
249-
- signingConfig = signingConfigs.getByName("debug")
250-
+ signingConfig = signingConfigs.getByName("release")
251-
}
252-
}
253-
...
254-
}
255-
```
277+
<Tabs key="android-signing-config">
278+
<Tab name="Kotlin">
279+
280+
```kotlin diff title="[project]/android/app/build.gradle.kts"
281+
android {
282+
// ...
283+
284+
+ signingConfigs {
285+
+ create("release") {
286+
+ keyAlias = keystoreProperties["keyAlias"] as String
287+
+ keyPassword = keystoreProperties["keyPassword"] as String
288+
+ storeFile = keystoreProperties["storeFile"]?.let { file(it) }
289+
+ storePassword = keystoreProperties["storePassword"] as String
290+
+ }
291+
+ }
292+
buildTypes {
293+
release {
294+
// TODO: Add your own signing config for the release build.
295+
// Signing with the debug keys for now,
296+
// so `flutter run --release` works.
297+
- signingConfig = signingConfigs.getByName("debug")
298+
+ signingConfig = signingConfigs.getByName("release")
299+
}
300+
}
301+
...
302+
}
303+
```
304+
305+
</Tab>
306+
<Tab name="Groovy">
307+
308+
```groovy diff title="[project]/android/app/build.gradle"
309+
android {
310+
// ...
311+
312+
+ signingConfigs {
313+
+ release {
314+
+ keyAlias = keystoreProperties['keyAlias']
315+
+ keyPassword = keystoreProperties['keyPassword']
316+
+ storeFile = keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
317+
+ storePassword = keystoreProperties['storePassword']
318+
+ }
319+
+ }
320+
buildTypes {
321+
release {
322+
// TODO: Add your own signing config for the release build.
323+
// Signing with the debug keys for now,
324+
// so `flutter run --release` works.
325+
- signingConfig = signingConfigs.debug
326+
+ signingConfig = signingConfigs.release
327+
}
328+
}
329+
...
330+
}
331+
```
332+
333+
</Tab>
334+
</Tabs>
256335

257336
Flutter now signs all release builds.
258337

0 commit comments

Comments
 (0)