-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
android: Migrate Flutter project to new Gradle plugin syntax
Migrate Flutter project to the new Gradle plugin syntax recommended in Flutter 3.16. * Updated settings.gradle to use the pluginManagement and plugins blocks instead of the legacy apply script method. * Removed the buildscript block from android/build.gradle. * Removed the legacy apply plugin statements from android/app/build.gradle. * Removed the unnecessary dependencies block for Kotlin in android/app/build.gradle. Benefits: * Improves readability and maintainability of Gradle build files. * Makes it easier for the Flutter team to develop and release new features. * Prepares the project for future changes in Flutter Gradle plugin support. References: * Flutter Gradle Plugin Apply: https://flutter.dev/go/flutter-gradle-plugin-apply
- Loading branch information
Showing
5 changed files
with
38 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,25 @@ | ||
include ':app' | ||
pluginManagement { | ||
def flutterSdkPath = { | ||
def properties = new Properties() | ||
file("local.properties").withInputStream { properties.load(it) } | ||
def flutterSdkPath = properties.getProperty("flutter.sdk") | ||
assert flutterSdkPath != null, "flutter.sdk not set in local.properties" | ||
return flutterSdkPath | ||
}() | ||
|
||
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() | ||
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") | ||
|
||
def plugins = new Properties() | ||
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') | ||
if (pluginsFile.exists()) { | ||
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } | ||
repositories { | ||
google() | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
plugins.each { name, path -> | ||
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() | ||
include ":$name" | ||
project(":$name").projectDir = pluginDirectory | ||
plugins { | ||
id "dev.flutter.flutter-plugin-loader" version "1.0.0" | ||
id "com.android.application" version "8.1.0" apply false // Replace with your AGP version | ||
id "org.jetbrains.kotlin.android" version "1.8.22" apply false // Replace with your Kotlin version | ||
} | ||
|
||
include ":app" |