Skip to content

Commit

Permalink
Migrates away from Android imperative gradle api
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanbeusekom committed Nov 14, 2024
1 parent 17931df commit 1a90e4a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 33 deletions.
3 changes: 2 additions & 1 deletion geolocator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 13.0.2

- Updates dependency on geolocator_apple to version 2.3.8
- Updates dependency on geolocator_apple to version 2.3.8.
- Migrates Android configuration of example app away from imperative gradle API.

## 13.0.1

Expand Down
17 changes: 7 additions & 10 deletions geolocator/example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
plugins {
id "com.android.application"
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +11,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand All @@ -27,17 +27,14 @@ project.getTasks().withType(JavaCompile) {
options.compilerArgs.addAll(args)
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 33
compileSdkVersion 34


defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.baseflow.geolocator_example"
minSdkVersion 16
minSdkVersion flutter.minSdkVersion
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
13 changes: 1 addition & 12 deletions geolocator/example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
buildscript {
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
}
}

allprojects {
repositories {
google()
Expand All @@ -24,6 +13,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
29 changes: 19 additions & 10 deletions geolocator/example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
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 "7.1.2" apply false
}

include ":app"

0 comments on commit 1a90e4a

Please sign in to comment.