|
| 1 | +plugins { |
| 2 | + id "com.android.application" |
| 3 | + id "kotlin-android" |
| 4 | + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. |
| 5 | + id "dev.flutter.flutter-gradle-plugin" |
| 6 | +} |
| 7 | + |
1 | 8 | def localProperties = new Properties() |
2 | | -def localPropertiesFile = rootProject.file('local.properties') |
| 9 | +def localPropertiesFile = rootProject.file("local.properties") |
3 | 10 | if (localPropertiesFile.exists()) { |
4 | | - localPropertiesFile.withReader('UTF-8') { reader -> |
| 11 | + localPropertiesFile.withReader("UTF-8") { reader -> |
5 | 12 | localProperties.load(reader) |
6 | 13 | } |
7 | 14 | } |
8 | 15 |
|
9 | | -def flutterRoot = localProperties.getProperty('flutter.sdk') |
10 | | -if (flutterRoot == null) { |
11 | | - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") |
12 | | -} |
13 | | - |
14 | | -def flutterVersionCode = localProperties.getProperty('flutter.versionCode') |
| 16 | +def flutterVersionCode = localProperties.getProperty("flutter.versionCode") |
15 | 17 | if (flutterVersionCode == null) { |
16 | | - flutterVersionCode = '1' |
| 18 | + flutterVersionCode = "1" |
17 | 19 | } |
18 | 20 |
|
19 | | -def flutterVersionName = localProperties.getProperty('flutter.versionName') |
| 21 | +def flutterVersionName = localProperties.getProperty("flutter.versionName") |
20 | 22 | if (flutterVersionName == null) { |
21 | | - flutterVersionName = '1.0' |
| 23 | + flutterVersionName = "1.0" |
22 | 24 | } |
23 | 25 |
|
24 | | -apply plugin: 'com.android.application' |
25 | | -apply plugin: 'kotlin-android' |
26 | | -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" |
| 26 | + |
| 27 | +// TODO: Change the appName, it will be used as app label |
| 28 | +def appName = "Flutter Template" |
| 29 | + |
| 30 | +// TODO: Change the applicationId for production |
| 31 | +// On staging it will add .staging and on development it will add .development as suffix. |
| 32 | +def applicationId = "com.example.flutter_template" |
| 33 | + |
27 | 34 |
|
28 | 35 | android { |
29 | | - compileSdkVersion flutter.compileSdkVersion |
| 36 | + namespace = "$applicationId" |
| 37 | + compileSdk = flutter.compileSdkVersion |
| 38 | + ndkVersion = flutter.ndkVersion |
30 | 39 |
|
31 | 40 | compileOptions { |
32 | | - sourceCompatibility JavaVersion.VERSION_1_8 |
33 | | - targetCompatibility JavaVersion.VERSION_1_8 |
| 41 | + sourceCompatibility = JavaVersion.VERSION_1_8 |
| 42 | + targetCompatibility = JavaVersion.VERSION_1_8 |
34 | 43 | } |
35 | 44 |
|
36 | 45 | kotlinOptions { |
37 | | - jvmTarget = '1.8' |
38 | | - } |
39 | | - |
40 | | - sourceSets { |
41 | | - main.java.srcDirs += 'src/main/kotlin' |
| 46 | + jvmTarget = JavaVersion.VERSION_1_8 |
42 | 47 | } |
43 | 48 |
|
44 | 49 | defaultConfig { |
45 | | - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). |
46 | | - applicationId "com.example.flutter_template" |
47 | | - minSdkVersion flutter.minSdkVersion |
48 | | - targetSdkVersion flutter.targetSdkVersion |
49 | | - versionCode flutterVersionCode.toInteger() |
50 | | - versionName flutterVersionName |
| 50 | + applicationId = "$applicationId" |
| 51 | + // You can update the following values to match your application needs. |
| 52 | + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. |
| 53 | + minSdk = flutter.minSdkVersion |
| 54 | + targetSdk = flutter.targetSdkVersion |
| 55 | + versionCode = flutterVersionCode.toInteger() |
| 56 | + versionName = flutterVersionName |
51 | 57 | } |
52 | 58 |
|
53 | 59 | buildTypes { |
54 | 60 | release { |
55 | 61 | // TODO: Add your own signing config for the release build. |
56 | 62 | // Signing with the debug keys for now, so `flutter run --release` works. |
57 | | - signingConfig signingConfigs.debug |
| 63 | + signingConfig = signingConfigs.debug |
58 | 64 | } |
59 | 65 | } |
60 | | - |
61 | 66 | //TODO: Change resValue application name |
62 | | - flavorDimensions "flavor-type" |
| 67 | + flavorDimensions.add("flavor-type") |
63 | 68 |
|
64 | 69 | productFlavors { |
65 | | - development { |
66 | | - dimension "flavor-type" |
67 | | - applicationIdSuffix ".development" |
68 | | - versionNameSuffix "-development" |
69 | | - resValue "string", "app_name", "Application Name Development" |
70 | | - signingConfig signingConfigs.debug |
| 70 | + create("development") { |
| 71 | + dimension = "flavor-type" |
| 72 | + applicationIdSuffix = ".development" |
| 73 | + versionNameSuffix = "-development" |
| 74 | + manifestPlaceholders["appName"] = "[DEV] $appName" |
| 75 | + signingConfig = signingConfigs.getByName("debug") |
71 | 76 | } |
72 | | - staging { |
73 | | - dimension "flavor-type" |
74 | | - applicationIdSuffix ".staging" |
75 | | - versionNameSuffix "-staging" |
76 | | - resValue "string", "app_name", "Application Name Staging" |
77 | | - signingConfig signingConfigs.debug |
| 77 | + create("staging") { |
| 78 | + dimension = "flavor-type" |
| 79 | + applicationIdSuffix = ".staging" |
| 80 | + versionNameSuffix = "-staging" |
| 81 | + manifestPlaceholders["appName"] = "[STG] $appName" |
| 82 | + signingConfig = signingConfigs.getByName("debug") |
78 | 83 | } |
79 | | - production { |
80 | | - dimension "flavor-type" |
81 | | - resValue "string", "app_name", "Application Name" |
82 | | - // TODO: After adding your own signing config for the release build. |
83 | | - // Change this to signingConfigs.release |
84 | | - signingConfig signingConfigs.debug |
| 84 | + create("production") { |
| 85 | + dimension = "flavor-type" |
| 86 | + manifestPlaceholders["appName"] = "$appName" |
| 87 | + // TODO: After adding your own signing config for the release build, |
| 88 | + // Change this to |
| 89 | + // signingConfig = signingConfigs.getByName("release") |
| 90 | + signingConfig = signingConfigs.getByName("debug") |
85 | 91 | } |
86 | | - |
87 | 92 | } |
88 | 93 | } |
89 | 94 |
|
90 | 95 | flutter { |
91 | | - source '../..' |
92 | | -} |
93 | | - |
94 | | -dependencies { |
95 | | - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" |
| 96 | + source = "../.." |
96 | 97 | } |
0 commit comments