Skip to content

Commit 540a327

Browse files
authored
chore: Migrated to android gradle plugin (#145)
1 parent f42bd7f commit 540a327

36 files changed

+218
-161
lines changed

.metadata

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,27 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: 9b2d32b605630f28625709ebd9d78ab3016b2bf6
8-
channel: stable
7+
revision: "5dcb86f68f239346676ceb1ed1ea385bd215fba1"
8+
channel: "stable"
99

1010
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1
17+
base_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1
18+
- platform: ios
19+
create_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1
20+
base_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1
21+
22+
# User provided section
23+
24+
# List of Local paths (relative to this file) that should be
25+
# ignored by the migrate tool.
26+
#
27+
# Files that are not part of the templates will be ignored by default.
28+
unmanaged_files:
29+
- 'lib/main.dart'
30+
- 'ios/Runner.xcodeproj/project.pbxproj'

.run/development_debug.run.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Developement Debug" type="FlutterRunConfigurationType" factoryName="Flutter">
3+
<option name="filePath" value="$PROJECT_DIR$/lib/main_developement.dart" />
4+
<method v="2" />
5+
</configuration>
6+
</component>

.run/development_release.run.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Developement Release" type="FlutterRunConfigurationType" factoryName="Flutter">
3+
<option name="additionalArgs" value="--release" />
4+
<option name="filePath" value="$PROJECT_DIR$/lib/main_developement.dart" />
5+
<method v="2" />
6+
</configuration>
7+
</component>

.run/production_debug.run.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.run/production_release.run.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

.run/staging_debug.run.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
<option name="filePath" value="$PROJECT_DIR$/lib/main_staging.dart" />
44
<method v="2" />
55
</configuration>
6-
</component>
6+
</component>

.run/staging_release.run.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
<option name="filePath" value="$PROJECT_DIR$/lib/main_staging.dart" />
55
<method v="2" />
66
</configuration>
7-
</component>
7+
</component>

.vscode/launch.json

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,35 @@
11
{
2-
// Use IntelliSense to learn about possible attributes.
3-
// Hover to view descriptions of existing attributes.
4-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5-
"version": "0.2.0",
6-
"configurations": [
7-
{
8-
"name": "Development",
9-
"request": "launch",
10-
"type": "dart",
11-
"program": "lib/main_development.dart",
12-
"args": [
13-
"--flavor",
14-
"development"
15-
]
16-
},
17-
{
18-
"name": "Staging",
19-
"request": "launch",
20-
"type": "dart",
21-
"program": "lib/main_staging.dart",
22-
"args": [
23-
"--flavor",
24-
"staging"
25-
]
26-
},
27-
{
28-
"name": "Production",
29-
"request": "launch",
30-
"type": "dart",
31-
"program": "lib/main_production.dart",
32-
"args": [
33-
"--flavor",
34-
"production"
35-
]
36-
},
37-
]
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Development",
9+
"request": "launch",
10+
"type": "dart",
11+
"program": "lib/main_development.dart",
12+
"args": ["--flavor", "development"]
13+
},
14+
{
15+
"name": "Staging",
16+
"request": "launch",
17+
"type": "dart",
18+
"program": "lib/main_staging.dart",
19+
"args": ["--flavor", "staging"]
20+
}
21+
22+
// Commented to avoid running the product app from VSCode
23+
// Uncomment only if we really need it
24+
// {
25+
// "name": "Production",
26+
// "request": "launch",
27+
// "type": "dart",
28+
// "program": "lib/main_production.dart",
29+
// "args": [
30+
// "--flavor",
31+
// "production"
32+
// ]
33+
// },
34+
]
3835
}

android/app/build.gradle

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,97 @@
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+
18
def localProperties = new Properties()
2-
def localPropertiesFile = rootProject.file('local.properties')
9+
def localPropertiesFile = rootProject.file("local.properties")
310
if (localPropertiesFile.exists()) {
4-
localPropertiesFile.withReader('UTF-8') { reader ->
11+
localPropertiesFile.withReader("UTF-8") { reader ->
512
localProperties.load(reader)
613
}
714
}
815

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")
1517
if (flutterVersionCode == null) {
16-
flutterVersionCode = '1'
18+
flutterVersionCode = "1"
1719
}
1820

19-
def flutterVersionName = localProperties.getProperty('flutter.versionName')
21+
def flutterVersionName = localProperties.getProperty("flutter.versionName")
2022
if (flutterVersionName == null) {
21-
flutterVersionName = '1.0'
23+
flutterVersionName = "1.0"
2224
}
2325

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+
2734

2835
android {
29-
compileSdkVersion flutter.compileSdkVersion
36+
namespace = "$applicationId"
37+
compileSdk = flutter.compileSdkVersion
38+
ndkVersion = flutter.ndkVersion
3039

3140
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
3443
}
3544

3645
kotlinOptions {
37-
jvmTarget = '1.8'
38-
}
39-
40-
sourceSets {
41-
main.java.srcDirs += 'src/main/kotlin'
46+
jvmTarget = JavaVersion.VERSION_1_8
4247
}
4348

4449
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
5157
}
5258

5359
buildTypes {
5460
release {
5561
// TODO: Add your own signing config for the release build.
5662
// Signing with the debug keys for now, so `flutter run --release` works.
57-
signingConfig signingConfigs.debug
63+
signingConfig = signingConfigs.debug
5864
}
5965
}
60-
6166
//TODO: Change resValue application name
62-
flavorDimensions "flavor-type"
67+
flavorDimensions.add("flavor-type")
6368

6469
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")
7176
}
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")
7883
}
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")
8591
}
86-
8792
}
8893
}
8994

9095
flutter {
91-
source '../..'
92-
}
93-
94-
dependencies {
95-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
96+
source = "../.."
9697
}

android/app/src/debug/AndroidManifest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.example.flutter_template">
3-
<!-- Flutter needs it to communicate with the running application
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<!-- The INTERNET permission is required for development. Specifically,
3+
the Flutter tool needs it to communicate with the running application
44
to allow setting breakpoints, to provide hot reload, etc.
55
-->
66
<uses-permission android:name="android.permission.INTERNET"/>

0 commit comments

Comments
 (0)