Skip to content

Commit 2961096

Browse files
committed
fix: Deprecated imperative apply of Flutter's Gradle plugins
1 parent a46ffd2 commit 2961096

File tree

10 files changed

+85
-82
lines changed

10 files changed

+85
-82
lines changed

android/app/build.gradle

+36-40
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
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
}
@@ -17,71 +24,60 @@ if (flutterRoot == null) {
1724
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
1825
}
1926

20-
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
27+
def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
2128
if (flutterVersionCode == null) {
22-
flutterVersionCode = '1'
29+
flutterVersionCode = "1"
2330
}
2431

25-
def flutterVersionName = localProperties.getProperty('flutter.versionName')
32+
def flutterVersionName = localProperties.getProperty("flutter.versionName")
2633
if (flutterVersionName == null) {
27-
flutterVersionName = '1.0'
34+
flutterVersionName = "1.0"
2835
}
2936

30-
apply plugin: 'com.android.application'
31-
apply plugin: 'kotlin-android'
32-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
33-
3437
android {
35-
compileSdkVersion flutter.compileSdkVersion
38+
namespace = "com.example.chemobile"
39+
compileSdk = flutter.compileSdkVersion
40+
ndkVersion = flutter.ndkVersion
3641

3742
compileOptions {
38-
sourceCompatibility JavaVersion.VERSION_1_8
39-
targetCompatibility JavaVersion.VERSION_1_8
40-
}
41-
42-
kotlinOptions {
43-
jvmTarget = '1.8'
44-
}
45-
46-
sourceSets {
47-
main.java.srcDirs += 'src/main/kotlin'
43+
sourceCompatibility = JavaVersion.VERSION_1_8
44+
targetCompatibility = JavaVersion.VERSION_1_8
4845
}
4946

5047
defaultConfig {
51-
applicationId "com.chemotion.chemobile"
52-
minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
53-
targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()
54-
versionCode flutterVersionCode.toInteger()
55-
versionName flutterVersionName
48+
// You can update the following values to match your application needs.
49+
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
50+
applicationId = "com.chemotion.chemobile"
51+
minSdk = localProperties.getProperty('flutter.minSdkVersion').toInteger()
52+
targetSdk = localProperties.getProperty('flutter.targetSdkVersion').toInteger()
53+
versionCode = flutterVersionCode.toInteger()
54+
versionName = flutterVersionName
5655
}
5756

5857
signingConfigs {
5958
release {
6059
if (keystorePropertiesFile.exists()) {
61-
keyAlias keystoreProperties['keyAlias']
62-
keyPassword keystoreProperties['keyPassword']
63-
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
64-
storePassword keystoreProperties['storePassword']
60+
keyAlias = keystoreProperties['keyAlias']
61+
keyPassword = keystoreProperties['keyPassword']
62+
storeFile = keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
63+
storePassword = keystoreProperties['storePassword']
6564
}
6665
}
6766
}
67+
6868
buildTypes {
6969
release {
70-
if (keystorePropertiesFile.exists()) {
71-
println "Signing with key.properties"
72-
signingConfig signingConfigs.release
70+
if (keystorePropertiesFile.exists()) {
71+
println "Signing with key.properties"
72+
signingConfig = signingConfigs.release
7373
} else {
74-
println "Signing with debug keys"
75-
signingConfig signingConfigs.debug
74+
println "Signing with debug keys"
75+
signingConfig = signingConfigs.debug
7676
}
7777
}
7878
}
7979
}
8080

8181
flutter {
82-
source '../..'
83-
}
84-
85-
dependencies {
86-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
82+
source = "../.."
8783
}
+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.example.chemobile">
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"/>
7-
<uses-permission android:name="android.permission.VIBRATE"/>
87
</manifest>

android/app/src/main/AndroidManifest.xml

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.example.chemobile">
3-
<application
4-
android:label="chemobile"
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<application
3+
android:label="my_app"
54
android:name="${applicationName}"
65
android:icon="@mipmap/ic_launcher">
76
<activity
87
android:name=".MainActivity"
9-
android:screenOrientation="portrait"
108
android:exported="true"
119
android:launchMode="singleTop"
10+
android:taskAffinity=""
1211
android:theme="@style/LaunchTheme"
1312
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
1413
android:hardwareAccelerated="true"
@@ -32,4 +31,15 @@
3231
android:name="flutterEmbedding"
3332
android:value="2" />
3433
</application>
34+
<!-- Required to query activities that can process text, see:
35+
https://developer.android.com/training/package-visibility and
36+
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
37+
38+
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
39+
<queries>
40+
<intent>
41+
<action android:name="android.intent.action.PROCESS_TEXT"/>
42+
<data android:mimeType="text/plain"/>
43+
</intent>
44+
</queries>
3545
</manifest>

android/app/src/main/res/values-night/styles.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
44
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
55
<!-- Show a splash screen on the activity. Automatically removed when
6-
Flutter draws its first frame -->
6+
the Flutter engine draws its first frame -->
77
<item name="android:windowBackground">@drawable/launch_background</item>
88
</style>
99
<!-- Theme applied to the Android Window as soon as the process has started.

android/app/src/main/res/values/styles.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
44
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
55
<!-- Show a splash screen on the activity. Automatically removed when
6-
Flutter draws its first frame -->
6+
the Flutter engine draws its first frame -->
77
<item name="android:windowBackground">@drawable/launch_background</item>
88
</style>
99
<!-- Theme applied to the Android Window as soon as the process has started.
+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.example.chemobile">
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"/>
7-
<uses-permission android:name="android.permission.VIBRATE"/>
87
</manifest>

android/build.gradle

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
1-
buildscript {
2-
ext.kotlin_version = '1.7.10'
3-
repositories {
4-
google()
5-
mavenCentral()
6-
}
7-
8-
dependencies {
9-
classpath 'com.android.tools.build:gradle:7.3.0'
10-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11-
}
12-
}
13-
141
allprojects {
152
repositories {
163
google()
174
mavenCentral()
185
}
196
}
207

21-
rootProject.buildDir = '../build'
8+
rootProject.buildDir = "../build"
229
subprojects {
2310
project.buildDir = "${rootProject.buildDir}/${project.name}"
2411
}
2512
subprojects {
26-
project.evaluationDependsOn(':app')
13+
project.evaluationDependsOn(":app")
2714
}
2815

2916
tasks.register("clean", Delete) {

android/gradle.properties

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
org.gradle.jvmargs=-Xmx1536M
1+
org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError
22
android.useAndroidX=true
33
android.enableJetifier=true
4-
firebasePerformanceInstrumentationEnabled=false
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Fri Jun 23 08:50:38 CEST 2017
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
43
zipStoreBase=GRADLE_USER_HOME
54
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip

android/settings.gradle

+22-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
include ':app'
1+
pluginManagement {
2+
def flutterSdkPath = {
3+
def properties = new Properties()
4+
file("local.properties").withInputStream { properties.load(it) }
5+
def flutterSdkPath = properties.getProperty("flutter.sdk")
6+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7+
return flutterSdkPath
8+
}()
29

3-
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4-
def properties = new Properties()
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
511

6-
assert localPropertiesFile.exists()
7-
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
17+
}
818

9-
def flutterSdkPath = properties.getProperty("flutter.sdk")
10-
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11-
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
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+
}
24+
25+
include ":app"

0 commit comments

Comments
 (0)