From 75b64a00b2abd7ab6119d392cd343c9fff91d75b Mon Sep 17 00:00:00 2001
From: Sebastian Roth <sebastian.roth@gmail.com>
Date: Fri, 22 Sep 2023 06:37:23 +0100
Subject: [PATCH 1/4] feat: Gradle 8 + AGP upgrade (#505)

* Gradle 8 + AGP upgrade

* compileSdk

* java17 in workflows

* few gh action updates
---
 .github/workflows/analysis.yml                |  2 +-
 .github/workflows/examples.yml                |  6 +--
 .github/workflows/format.yml                  |  8 ++--
 .github/workflows/test.yml                    | 14 +++----
 android/build.gradle                          | 25 ++++++++---
 android/src/main/AndroidManifest.xml          |  2 +-
 .../workmanager/BackgroundWorker.kt           |  2 +-
 .../workmanager/DebugHelper.kt                |  2 +-
 .../workmanager/Extractor.kt                  | 42 +++++++++----------
 .../workmanager/SharedPreferenceHelper.kt     |  2 +-
 .../workmanager/WorkmanagerCallHandler.kt     |  8 ++--
 .../workmanager/WorkmanagerPlugin.kt          |  4 +-
 android/src/test/java/ExtractorTests.kt       |  2 +-
 example/android/app/build.gradle              | 24 ++++++++---
 .../example/EmbeddingV1Activity.kt            |  6 ---
 .../example/EmbeddingV1Application.kt         | 18 --------
 example/android/build.gradle                  |  6 +--
 example/android/gradle.properties             |  5 ++-
 .../gradle/wrapper/gradle-wrapper.properties  |  2 +-
 example/pubspec.yaml                          |  2 +-
 pubspec.yaml                                  |  2 +-
 21 files changed, 95 insertions(+), 89 deletions(-)
 rename android/src/main/kotlin/{be/tramckrijte => dev/fluttercommunity}/workmanager/BackgroundWorker.kt (99%)
 rename android/src/main/kotlin/{be/tramckrijte => dev/fluttercommunity}/workmanager/DebugHelper.kt (98%)
 rename android/src/main/kotlin/{be/tramckrijte => dev/fluttercommunity}/workmanager/Extractor.kt (85%)
 rename android/src/main/kotlin/{be/tramckrijte => dev/fluttercommunity}/workmanager/SharedPreferenceHelper.kt (95%)
 rename android/src/main/kotlin/{be/tramckrijte => dev/fluttercommunity}/workmanager/WorkmanagerCallHandler.kt (97%)
 rename android/src/main/kotlin/{be/tramckrijte => dev/fluttercommunity}/workmanager/WorkmanagerPlugin.kt (94%)
 delete mode 100644 example/android/app/src/main/kotlin/dev/fluttercommunity/workmanager/example/EmbeddingV1Activity.kt
 delete mode 100644 example/android/app/src/main/kotlin/dev/fluttercommunity/workmanager/example/EmbeddingV1Application.kt

diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml
index 0f3e1794..3f6ac186 100644
--- a/.github/workflows/analysis.yml
+++ b/.github/workflows/analysis.yml
@@ -5,7 +5,7 @@ jobs:
   package-analysis:
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - uses: axel-op/dart-package-analyzer@v3
         with:
           # Required:
diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml
index 56e40567..d40d2266 100644
--- a/.github/workflows/examples.yml
+++ b/.github/workflows/examples.yml
@@ -10,10 +10,10 @@ jobs:
   example_android:
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - uses: actions/setup-java@v1
         with:
-          java-version: 11
+          java-version: 17
       - uses: subosito/flutter-action@v2
         with:
           channel: "stable"
@@ -25,7 +25,7 @@ jobs:
   example_ios:
     runs-on: macos-latest
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - uses: subosito/flutter-action@v2
         with:
           channel: "stable"
diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml
index b33442b2..d03b8e21 100644
--- a/.github/workflows/format.yml
+++ b/.github/workflows/format.yml
@@ -10,7 +10,7 @@ jobs:
   format_dart:
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - uses: subosito/flutter-action@v2
         with:
           channel: 'stable'
@@ -23,7 +23,7 @@ jobs:
 
     steps:
       - name: "checkout"
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
 
       - name: "ktlint"
         uses: "vroy/gha-kotlin-linter@v1"
@@ -31,14 +31,14 @@ jobs:
   format_swift:
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - name: GitHub Action for SwiftLint
         uses: norio-nomura/action-swiftlint@3.2.1
 
   publishable:
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - uses: subosito/flutter-action@v2
         with:
           channel: 'stable'
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 5106bb60..d3943c45 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -10,7 +10,7 @@ jobs:
   test:
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - uses: subosito/flutter-action@v2
         with:
           channel: 'stable'
@@ -22,7 +22,7 @@ jobs:
   native_ios_tests:
     runs-on: macos-latest
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - uses: subosito/flutter-action@v2
         with:
           channel: 'stable'
@@ -34,10 +34,10 @@ jobs:
   native_android_tests:
     runs-on: macos-latest
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - uses: actions/setup-java@v1
         with:
-          java-version: 11
+          java-version: 17
       - uses: subosito/flutter-action@v1
         with:
           channel: 'stable'
@@ -57,7 +57,7 @@ jobs:
       - uses: futureware-tech/simulator-action@v1
         with:
           model: '${{ matrix.device }}'
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - uses: subosito/flutter-action@v2
         with:
           channel: 'stable'
@@ -76,10 +76,10 @@ jobs:
         # api-level: [21, 29]
         target: [default]
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - uses: actions/setup-java@v1
         with:
-          java-version: 11
+          java-version: 17
       - uses: subosito/flutter-action@v2
         with:
           channel: 'stable'
diff --git a/android/build.gradle b/android/build.gradle
index 79a7810a..56af979f 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -1,15 +1,15 @@
-group 'be.tramckrijte.workmanager'
+group 'dev.fluttercommunity.workmanager'
 version '1.0-SNAPSHOT'
 
 buildscript {
-    ext.kotlin_version = '1.7.10'
+    ext.kotlin_version = '1.8.10'
     repositories {
         google()
         mavenCentral()
     }
 
     dependencies {
-        classpath 'com.android.tools.build:gradle:7.1.3'
+        classpath 'com.android.tools.build:gradle:8.0.2'
         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
     }
 }
@@ -25,18 +25,33 @@ apply plugin: 'com.android.library'
 apply plugin: 'kotlin-android'
 
 android {
-    compileSdkVersion 33
+    // Conditional for compatibility with AGP <4.2.
+    if (project.android.hasProperty("namespace")) {
+        namespace 'dev.fluttercommunity.workmanager'
+    }
 
     sourceSets {
         main.java.srcDirs += 'src/main/kotlin'
     }
     defaultConfig {
-        minSdkVersion 16
+        compileSdk 33
+        minSdkVersion 19
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
     lintOptions {
         disable 'InvalidPackage'
     }
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
+
+    kotlinOptions {
+        tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
+            kotlinOptions.jvmTarget = "1.8"
+        }
+    }
+
 }
 
 dependencies {
diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml
index 2cd4a0b9..92a5a432 100644
--- a/android/src/main/AndroidManifest.xml
+++ b/android/src/main/AndroidManifest.xml
@@ -1,2 +1,2 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="be.tramckrijte.workmanager">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="dev.fluttercommunity.workmanager">
 </manifest>
diff --git a/android/src/main/kotlin/be/tramckrijte/workmanager/BackgroundWorker.kt b/android/src/main/kotlin/dev/fluttercommunity/workmanager/BackgroundWorker.kt
similarity index 99%
rename from android/src/main/kotlin/be/tramckrijte/workmanager/BackgroundWorker.kt
rename to android/src/main/kotlin/dev/fluttercommunity/workmanager/BackgroundWorker.kt
index 62791eef..ec8c868b 100644
--- a/android/src/main/kotlin/be/tramckrijte/workmanager/BackgroundWorker.kt
+++ b/android/src/main/kotlin/dev/fluttercommunity/workmanager/BackgroundWorker.kt
@@ -1,4 +1,4 @@
-package be.tramckrijte.workmanager
+package dev.fluttercommunity.workmanager
 
 import android.content.Context
 import android.os.Handler
diff --git a/android/src/main/kotlin/be/tramckrijte/workmanager/DebugHelper.kt b/android/src/main/kotlin/dev/fluttercommunity/workmanager/DebugHelper.kt
similarity index 98%
rename from android/src/main/kotlin/be/tramckrijte/workmanager/DebugHelper.kt
rename to android/src/main/kotlin/dev/fluttercommunity/workmanager/DebugHelper.kt
index 33beb295..08a200b1 100644
--- a/android/src/main/kotlin/be/tramckrijte/workmanager/DebugHelper.kt
+++ b/android/src/main/kotlin/dev/fluttercommunity/workmanager/DebugHelper.kt
@@ -1,4 +1,4 @@
-package be.tramckrijte.workmanager
+package dev.fluttercommunity.workmanager
 
 import android.app.NotificationChannel
 import android.app.NotificationManager
diff --git a/android/src/main/kotlin/be/tramckrijte/workmanager/Extractor.kt b/android/src/main/kotlin/dev/fluttercommunity/workmanager/Extractor.kt
similarity index 85%
rename from android/src/main/kotlin/be/tramckrijte/workmanager/Extractor.kt
rename to android/src/main/kotlin/dev/fluttercommunity/workmanager/Extractor.kt
index 3d12562f..61f3dc90 100644
--- a/android/src/main/kotlin/be/tramckrijte/workmanager/Extractor.kt
+++ b/android/src/main/kotlin/dev/fluttercommunity/workmanager/Extractor.kt
@@ -1,4 +1,4 @@
-package be.tramckrijte.workmanager
+package dev.fluttercommunity.workmanager
 
 import android.os.Build
 import androidx.annotation.VisibleForTesting
@@ -10,26 +10,26 @@ import androidx.work.NetworkType
 import androidx.work.OneTimeWorkRequest
 import androidx.work.OutOfQuotaPolicy
 import androidx.work.PeriodicWorkRequest
-import be.tramckrijte.workmanager.WorkManagerCall.CancelTask.ByTag.KEYS.UNREGISTER_TASK_TAG_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.CancelTask.ByUniqueName.KEYS.UNREGISTER_TASK_UNIQUE_NAME_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.Initialize.KEYS.INITIALIZE_TASK_CALL_HANDLE_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.Initialize.KEYS.INITIALIZE_TASK_IS_IN_DEBUG_MODE_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_BACK_OFF_POLICY_DELAY_MILLIS_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_BACK_OFF_POLICY_TYPE_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_CONSTRAINTS_BATTERY_NOT_LOW_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_CONSTRAINTS_CHARGING_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_CONSTRAINTS_DEVICE_IDLE_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_CONSTRAINTS_NETWORK_TYPE_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_CONSTRAINTS_STORAGE_NOT_LOW_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_EXISTING_WORK_POLICY_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_INITIAL_DELAY_SECONDS_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_IS_IN_DEBUG_MODE_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_NAME_VALUE_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_OUT_OF_QUOTA_POLICY_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_PAYLOAD_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_TAG_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_UNIQUE_NAME_KEY
-import be.tramckrijte.workmanager.WorkManagerCall.RegisterTask.PeriodicTask.KEYS.PERIODIC_TASK_FREQUENCY_SECONDS_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.CancelTask.ByTag.KEYS.UNREGISTER_TASK_TAG_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.CancelTask.ByUniqueName.KEYS.UNREGISTER_TASK_UNIQUE_NAME_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.Initialize.KEYS.INITIALIZE_TASK_CALL_HANDLE_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.Initialize.KEYS.INITIALIZE_TASK_IS_IN_DEBUG_MODE_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_BACK_OFF_POLICY_DELAY_MILLIS_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_BACK_OFF_POLICY_TYPE_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_CONSTRAINTS_BATTERY_NOT_LOW_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_CONSTRAINTS_CHARGING_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_CONSTRAINTS_DEVICE_IDLE_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_CONSTRAINTS_NETWORK_TYPE_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_CONSTRAINTS_STORAGE_NOT_LOW_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_EXISTING_WORK_POLICY_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_INITIAL_DELAY_SECONDS_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_IS_IN_DEBUG_MODE_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_NAME_VALUE_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_OUT_OF_QUOTA_POLICY_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_PAYLOAD_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_TAG_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_UNIQUE_NAME_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.PeriodicTask.KEYS.PERIODIC_TASK_FREQUENCY_SECONDS_KEY
 import io.flutter.plugin.common.MethodCall
 import kotlin.math.max
 
diff --git a/android/src/main/kotlin/be/tramckrijte/workmanager/SharedPreferenceHelper.kt b/android/src/main/kotlin/dev/fluttercommunity/workmanager/SharedPreferenceHelper.kt
similarity index 95%
rename from android/src/main/kotlin/be/tramckrijte/workmanager/SharedPreferenceHelper.kt
rename to android/src/main/kotlin/dev/fluttercommunity/workmanager/SharedPreferenceHelper.kt
index 11b46d37..0f13a08d 100644
--- a/android/src/main/kotlin/be/tramckrijte/workmanager/SharedPreferenceHelper.kt
+++ b/android/src/main/kotlin/dev/fluttercommunity/workmanager/SharedPreferenceHelper.kt
@@ -1,4 +1,4 @@
-package be.tramckrijte.workmanager
+package dev.fluttercommunity.workmanager
 
 import android.content.Context
 
diff --git a/android/src/main/kotlin/be/tramckrijte/workmanager/WorkmanagerCallHandler.kt b/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerCallHandler.kt
similarity index 97%
rename from android/src/main/kotlin/be/tramckrijte/workmanager/WorkmanagerCallHandler.kt
rename to android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerCallHandler.kt
index 36645ed7..d2f016c6 100644
--- a/android/src/main/kotlin/be/tramckrijte/workmanager/WorkmanagerCallHandler.kt
+++ b/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerCallHandler.kt
@@ -1,4 +1,4 @@
-package be.tramckrijte.workmanager
+package dev.fluttercommunity.workmanager
 
 import android.content.Context
 import androidx.work.Constraints
@@ -9,9 +9,9 @@ import androidx.work.OneTimeWorkRequest
 import androidx.work.OutOfQuotaPolicy
 import androidx.work.PeriodicWorkRequest
 import androidx.work.WorkManager
-import be.tramckrijte.workmanager.BackgroundWorker.Companion.DART_TASK_KEY
-import be.tramckrijte.workmanager.BackgroundWorker.Companion.IS_IN_DEBUG_MODE_KEY
-import be.tramckrijte.workmanager.BackgroundWorker.Companion.PAYLOAD_KEY
+import dev.fluttercommunity.workmanager.BackgroundWorker.Companion.DART_TASK_KEY
+import dev.fluttercommunity.workmanager.BackgroundWorker.Companion.IS_IN_DEBUG_MODE_KEY
+import dev.fluttercommunity.workmanager.BackgroundWorker.Companion.PAYLOAD_KEY
 import io.flutter.plugin.common.MethodCall
 import io.flutter.plugin.common.MethodChannel
 import java.util.concurrent.TimeUnit
diff --git a/android/src/main/kotlin/be/tramckrijte/workmanager/WorkmanagerPlugin.kt b/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt
similarity index 94%
rename from android/src/main/kotlin/be/tramckrijte/workmanager/WorkmanagerPlugin.kt
rename to android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt
index 0e581e93..eacaf04c 100644
--- a/android/src/main/kotlin/be/tramckrijte/workmanager/WorkmanagerPlugin.kt
+++ b/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt
@@ -1,4 +1,4 @@
-package be.tramckrijte.workmanager
+package dev.fluttercommunity.workmanager
 
 import android.content.Context
 import io.flutter.embedding.engine.plugins.FlutterPlugin
@@ -47,7 +47,7 @@ class WorkmanagerPlugin : FlutterPlugin {
         @Deprecated(message = "Use the Android v2 embedding method.")
         @JvmStatic
         fun setPluginRegistrantCallback(pluginRegistryCallback: PluginRegistry.PluginRegistrantCallback) {
-            WorkmanagerPlugin.pluginRegistryCallback = pluginRegistryCallback
+            Companion.pluginRegistryCallback = pluginRegistryCallback
         }
     }
 }
diff --git a/android/src/test/java/ExtractorTests.kt b/android/src/test/java/ExtractorTests.kt
index d44183f8..77dddeb9 100644
--- a/android/src/test/java/ExtractorTests.kt
+++ b/android/src/test/java/ExtractorTests.kt
@@ -1,6 +1,6 @@
 import androidx.work.NetworkType
 import androidx.work.OutOfQuotaPolicy
-import be.tramckrijte.workmanager.Extractor
+import dev.fluttercommunity.workmanager.Extractor
 import io.flutter.plugin.common.MethodCall
 import org.junit.Assert.assertEquals
 import org.junit.Test
diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle
index d6832459..38835d18 100644
--- a/example/android/app/build.gradle
+++ b/example/android/app/build.gradle
@@ -26,16 +26,19 @@ apply plugin: 'kotlin-android'
 apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
 
 android {
-    compileSdkVersion 33
-
     sourceSets {
         main.java.srcDirs += 'src/main/kotlin'
     }
 
+    // Conditional for compatibility with AGP <4.2.
+    if (project.android.hasProperty("namespace")) {
+        namespace 'dev.fluttercommunity.workmanager.example'
+    }
 
     defaultConfig {
         applicationId "dev.fluttercommunity.workmanager.example"
-        minSdkVersion 16
+        compileSdk 33
+        minSdkVersion 19
         targetSdkVersion 33
         versionCode flutterVersionCode.toInteger()
         versionName flutterVersionName
@@ -50,7 +53,16 @@ android {
         }
     }
 
-    namespace 'dev.fluttercommunity.workmanager.example'
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
+
+    kotlinOptions {
+        tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
+            kotlinOptions.jvmTarget = "1.8"
+        }
+    }
 
     lint {
         disable 'InvalidPackage'
@@ -64,6 +76,6 @@ flutter {
 dependencies {
     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
     testImplementation 'junit:junit:4.13.2'
-    androidTestImplementation 'com.android.support.test:runner:1.0.2'
-    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+    androidTestImplementation 'androidx.test:runner:1.5.2'
+    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
 }
diff --git a/example/android/app/src/main/kotlin/dev/fluttercommunity/workmanager/example/EmbeddingV1Activity.kt b/example/android/app/src/main/kotlin/dev/fluttercommunity/workmanager/example/EmbeddingV1Activity.kt
deleted file mode 100644
index 27c797c4..00000000
--- a/example/android/app/src/main/kotlin/dev/fluttercommunity/workmanager/example/EmbeddingV1Activity.kt
+++ /dev/null
@@ -1,6 +0,0 @@
-package dev.fluttercommunity.workmanager.example
-
-import io.flutter.app.FlutterActivity
-
-@Deprecated(message = "Not used, but here to show you how you can use the plugin using the old v1 embedding method.")
-class EmbeddingV1Activity : FlutterActivity()
diff --git a/example/android/app/src/main/kotlin/dev/fluttercommunity/workmanager/example/EmbeddingV1Application.kt b/example/android/app/src/main/kotlin/dev/fluttercommunity/workmanager/example/EmbeddingV1Application.kt
deleted file mode 100644
index b2b4558a..00000000
--- a/example/android/app/src/main/kotlin/dev/fluttercommunity/workmanager/example/EmbeddingV1Application.kt
+++ /dev/null
@@ -1,18 +0,0 @@
-package dev.fluttercommunity.workmanager.example
-
-import be.tramckrijte.workmanager.WorkmanagerPlugin
-import io.flutter.app.FlutterApplication
-import io.flutter.plugin.common.PluginRegistry
-
-@Deprecated(message = "Not used, but here to show you how you can use the plugin using the old v1 embedding method.")
-class EmbeddingV1Application : FlutterApplication(), PluginRegistry.PluginRegistrantCallback {
-    override fun registerWith(registry: PluginRegistry) {
-        // The line below this would be uncommented
-        // GeneratedPluginRegistrant.registerWith(registry)
-    }
-
-    override fun onCreate() {
-        super.onCreate()
-        WorkmanagerPlugin.setPluginRegistrantCallback(this)
-    }
-}
diff --git a/example/android/build.gradle b/example/android/build.gradle
index f6b10342..ce62641e 100644
--- a/example/android/build.gradle
+++ b/example/android/build.gradle
@@ -1,12 +1,12 @@
 buildscript {
-    ext.kotlin_version = '1.7.10'
+    ext.kotlin_version = '1.8.10'
     repositories {
         google()
         mavenCentral()
     }
 
     dependencies {
-        classpath 'com.android.tools.build:gradle:7.4.2'
+        classpath 'com.android.tools.build:gradle:8.1.1'
         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
     }
 }
@@ -30,6 +30,6 @@ subprojects {
     project.evaluationDependsOn(':app')
 }
 
-task clean(type: Delete) {
+tasks.register("clean", Delete) {
     delete rootProject.buildDir
 }
diff --git a/example/android/gradle.properties b/example/android/gradle.properties
index 2d223a0f..571b8974 100644
--- a/example/android/gradle.properties
+++ b/example/android/gradle.properties
@@ -1,4 +1,7 @@
 org.gradle.jvmargs=-Xmx1536M
 
 android.useAndroidX=true
-android.enableJetifier=false
\ No newline at end of file
+android.enableJetifier=false
+android.defaults.buildfeatures.buildconfig=true
+android.nonTransitiveRClass=false
+android.nonFinalResIds=false
\ No newline at end of file
diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties
index 757f139a..064431d8 100644
--- a/example/android/gradle/wrapper/gradle-wrapper.properties
+++ b/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.5-all.zip
\ No newline at end of file
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
\ No newline at end of file
diff --git a/example/pubspec.yaml b/example/pubspec.yaml
index a04ecbb1..4741dbbe 100644
--- a/example/pubspec.yaml
+++ b/example/pubspec.yaml
@@ -7,7 +7,7 @@ environment:
 
 dependencies:
   path_provider: ^2.0.11
-  shared_preferences: ^2.0.15
+  shared_preferences: ^2.2.1
   flutter:
     sdk: flutter
 
diff --git a/pubspec.yaml b/pubspec.yaml
index 12bd672f..a52a507a 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -26,7 +26,7 @@ flutter:
   plugin:
     platforms:
       android:
-        package: be.tramckrijte.workmanager
+        package: dev.fluttercommunity.workmanager
         pluginClass: WorkmanagerPlugin
       ios:
         pluginClass: WorkmanagerPlugin

From 61911a7151b58d9636c67151b7d45ee522289fcc Mon Sep 17 00:00:00 2001
From: Sebastian Roth <sebastian.roth@gmail.com>
Date: Fri, 22 Sep 2023 22:28:53 +0100
Subject: [PATCH 2/4] Enforce PR titles via GH action (#506)

---
 .github/workflows/pr.yml | 42 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 .github/workflows/pr.yml

diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml
new file mode 100644
index 00000000..671dbed6
--- /dev/null
+++ b/.github/workflows/pr.yml
@@ -0,0 +1,42 @@
+name: "Pull-Request Check"
+
+on:
+  pull_request_target:
+    types:
+      - opened
+      - edited
+      - synchronize
+
+jobs:
+  main:
+    name: Validate PR title
+    runs-on: ubuntu-latest
+    steps:
+      - uses: amannn/action-semantic-pull-request@v5.2.0
+        id: lint_pr_title
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+      - uses: marocchino/sticky-pull-request-comment@v2
+        # When the previous steps fails, the workflow would stop. By adding this
+        # condition you can continue the execution with the populated error message.
+        if: always() && (steps.lint_pr_title.outputs.error_message != null)
+        with:
+          header: pr-title-lint-error
+          message: |
+            Hey there and thank you for opening this pull request! 👋🏼
+
+            We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.
+
+            Details:
+
+            ```
+            ${{ steps.lint_pr_title.outputs.error_message }}
+            ```
+
+      # Delete a previous comment when the issue has been resolved
+      - if: ${{ steps.lint_pr_title.outputs.error_message == null }}
+        uses: marocchino/sticky-pull-request-comment@v2
+        with:
+          header: pr-title-lint-error
+          delete: true

From ab8a80a300cbe4a63521089bae56af51b29a3acd Mon Sep 17 00:00:00 2001
From: Sebastian Roth <sebastian.roth@gmail.com>
Date: Fri, 22 Sep 2023 23:06:42 +0100
Subject: [PATCH 3/4] Bump to workmanager 2.8.1 (#507)

---
 CHANGELOG.md                                                 | 2 ++
 android/build.gradle                                         | 2 +-
 .../kotlin/dev/fluttercommunity/workmanager/Extractor.kt     | 5 +++--
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2dbaa554..a7acc652 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,7 @@
 # next
 
+* Android: Bump to workmanager 2.8.1
+* Android: Move to Android Gradle Plugin 8.x
 * Android: Migrate away from ResolvableFuture (#399).
 
 # 0.5.1
diff --git a/android/build.gradle b/android/build.gradle
index 56af979f..44f13da7 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -57,7 +57,7 @@ android {
 dependencies {
     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
 
-    def work_version = "2.7.1"
+    def work_version = "2.8.1"
     implementation "androidx.work:work-runtime:$work_version"
     implementation "androidx.concurrent:concurrent-futures:1.1.0"
 
diff --git a/android/src/main/kotlin/dev/fluttercommunity/workmanager/Extractor.kt b/android/src/main/kotlin/dev/fluttercommunity/workmanager/Extractor.kt
index 61f3dc90..9c427b4c 100644
--- a/android/src/main/kotlin/dev/fluttercommunity/workmanager/Extractor.kt
+++ b/android/src/main/kotlin/dev/fluttercommunity/workmanager/Extractor.kt
@@ -10,6 +10,7 @@ import androidx.work.NetworkType
 import androidx.work.OneTimeWorkRequest
 import androidx.work.OutOfQuotaPolicy
 import androidx.work.PeriodicWorkRequest
+import androidx.work.WorkRequest
 import dev.fluttercommunity.workmanager.WorkManagerCall.CancelTask.ByTag.KEYS.UNREGISTER_TASK_TAG_KEY
 import dev.fluttercommunity.workmanager.WorkManagerCall.CancelTask.ByUniqueName.KEYS.UNREGISTER_TASK_UNIQUE_NAME_KEY
 import dev.fluttercommunity.workmanager.WorkManagerCall.Initialize.KEYS.INITIALIZE_TASK_CALL_HANDLE_KEY
@@ -147,8 +148,8 @@ sealed class WorkManagerCall {
 }
 
 private enum class TaskType(val minimumBackOffDelay: Long) {
-    ONE_OFF(OneTimeWorkRequest.MIN_BACKOFF_MILLIS),
-    PERIODIC(PeriodicWorkRequest.MIN_BACKOFF_MILLIS)
+    ONE_OFF(WorkRequest.MIN_BACKOFF_MILLIS),
+    PERIODIC(WorkRequest.MIN_BACKOFF_MILLIS)
 }
 
 object Extractor {

From 1ecec8d950d19d4affc7448d73111edb7da763c0 Mon Sep 17 00:00:00 2001
From: Sebastian Roth <sebastian.roth@gmail.com>
Date: Sat, 23 Sep 2023 09:56:30 +0100
Subject: [PATCH 4/4] docs: typo (#508)

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index e7e9ac7e..e56b260c 100644
--- a/README.md
+++ b/README.md
@@ -28,7 +28,7 @@ Before registering any task, the WorkManager plugin must be initialized.
 @pragma('vm:entry-point') // Mandatory if the App is obfuscated or using Flutter 3.1+
 void callbackDispatcher() {
   Workmanager().executeTask((task, inputData) {
-    print("Native called background task: $backgroundTask"); //simpleTask will be emitted here.
+    print("Native called background task: $task"); //simpleTask will be emitted here.
     return Future.value(true);
   });
 }