From a0ded20761c5a6926d8ef399c78e5ab14dfe12f9 Mon Sep 17 00:00:00 2001 From: Maurits van Beusekom Date: Thu, 17 Oct 2024 11:55:25 +0200 Subject: [PATCH] Depend on the min SDK version of Flutter installation (#1397) * Depend on the min SDK version of Flutter installation * Migrate away from deprecated imperative apply * Ensure git action works with Java 17 --- .../workflows/permission_handler_android.yaml | 6 ++++ permission_handler_android/CHANGELOG.md | 5 ++++ .../android/build.gradle | 2 +- .../example/android/app/build.gradle | 8 +++-- .../example/android/build.gradle | 13 ++------- .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../example/android/settings.gradle | 29 ++++++++++++------- permission_handler_android/pubspec.yaml | 2 +- 8 files changed, 40 insertions(+), 27 deletions(-) diff --git a/.github/workflows/permission_handler_android.yaml b/.github/workflows/permission_handler_android.yaml index cd745bf15..0bbe16316 100644 --- a/.github/workflows/permission_handler_android.yaml +++ b/.github/workflows/permission_handler_android.yaml @@ -33,6 +33,12 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v3 + # Make sure JAVA version 17 is installed on build agent. + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' # See 'Supported distributions' for available options + java-version: '17' + # Make sure the stable version of Flutter is available - uses: subosito/flutter-action@v2 with: diff --git a/permission_handler_android/CHANGELOG.md b/permission_handler_android/CHANGELOG.md index 3f1fce02b..37874ccd3 100644 --- a/permission_handler_android/CHANGELOG.md +++ b/permission_handler_android/CHANGELOG.md @@ -1,3 +1,8 @@ +## 12.0.13 + +* Updates the Android min SDK to 19 (from 16). +* Migrates example app away from deprecated imperative apply in gradle (see: https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply). + ## 12.0.12 * Fixes permission status returned from `Permission.photos.request()` or `Permission.videos.request()` when limited access selected diff --git a/permission_handler_android/android/build.gradle b/permission_handler_android/android/build.gradle index 73622f51d..8545dc8f4 100644 --- a/permission_handler_android/android/build.gradle +++ b/permission_handler_android/android/build.gradle @@ -34,6 +34,6 @@ android { } defaultConfig { - minSdkVersion 16 + minSdkVersion 19 } } diff --git a/permission_handler_android/example/android/app/build.gradle b/permission_handler_android/example/android/app/build.gradle index 93c36181d..56eb5bdf2 100644 --- a/permission_handler_android/example/android/app/build.gradle +++ b/permission_handler_android/example/android/app/build.gradle @@ -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()) { @@ -21,9 +26,6 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } -apply plugin: 'com.android.application' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - android { namespace 'com.baseflow.permissionhandler.example' compileSdk 34 diff --git a/permission_handler_android/example/android/build.gradle b/permission_handler_android/example/android/build.gradle index bd02a28c1..0ed2bee85 100644 --- a/permission_handler_android/example/android/build.gradle +++ b/permission_handler_android/example/android/build.gradle @@ -1,14 +1,3 @@ -buildscript { - repositories { - google() - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' - } -} - allprojects { repositories { google() @@ -19,6 +8,8 @@ allprojects { rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { project.evaluationDependsOn(':app') } diff --git a/permission_handler_android/example/android/gradle/wrapper/gradle-wrapper.properties b/permission_handler_android/example/android/gradle/wrapper/gradle-wrapper.properties index aeaff6f86..e6b38c2d6 100644 --- a/permission_handler_android/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/permission_handler_android/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip diff --git a/permission_handler_android/example/android/settings.gradle b/permission_handler_android/example/android/settings.gradle index 5a2f14fb1..68a23aebc 100644 --- a/permission_handler_android/example/android/settings.gradle +++ b/permission_handler_android/example/android/settings.gradle @@ -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 "8.1.0" apply false } + +include ":app" \ No newline at end of file diff --git a/permission_handler_android/pubspec.yaml b/permission_handler_android/pubspec.yaml index 4a911b56e..7d32908fa 100644 --- a/permission_handler_android/pubspec.yaml +++ b/permission_handler_android/pubspec.yaml @@ -1,7 +1,7 @@ name: permission_handler_android description: Permission plugin for Flutter. This plugin provides the Android API to request and check permissions. homepage: https://github.com/baseflow/flutter-permission-handler -version: 12.0.12 +version: 12.0.13 environment: sdk: ">=2.15.0 <4.0.0"