Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/desktop_drop/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.8.3

* [Android] Fix `Could not find method kotlin()` / `kotlinOptions()` on Gradle 9 / AGP 9 hosts by making the Kotlin configuration block itself conditional on the host AGP, complementing the conditional `apply plugin` from 0.8.2

## 0.8.2

* [Android] Restore compatibility with Android Gradle Plugin versions below 9 by applying the Kotlin Gradle Plugin conditionally, while continuing to use built-in Kotlin on AGP 9 and later [#495](https://github.com/MixinNetwork/flutter-plugins/pull/495)
Expand Down
32 changes: 20 additions & 12 deletions packages/desktop_drop/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,28 @@ buildscript {

apply plugin: 'com.android.library'

// Apply KGP only when the host does not provide built-in Kotlin.
// AGP 9+ ships Kotlin built-in and hard-fails if kotlin-android is applied,
// while hosts on AGP < 9 do not apply any Kotlin plugin to this subproject.
// See https://docs.flutter.dev/release/breaking-changes/migrate-to-built-in-kotlin/for-plugin-authors
// ("Support Flutter versions earlier than 3.44").
def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int
// AGP 9 has built-in Kotlin; applying KGP there fails.
// Hosts on AGP < 9 don't provide Kotlin for this plugin, so we apply it.
// Each AGP uses a different DSL for jvmTarget.
def agpMajor = 0
try {
agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
} catch (ignored) {
agpMajor = 0
}
if (agpMajor < 9) {
apply plugin: 'kotlin-android'
android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
} else {
kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
}
}
}

rootProject.allprojects {
Expand Down Expand Up @@ -55,12 +69,6 @@ android {
}
}

kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
2 changes: 1 addition & 1 deletion packages/desktop_drop/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: desktop_drop
resolution: workspace
description: A plugin which allows user dragging files to your flutter desktop applications.
version: 0.8.2
version: 0.8.3
homepage: https://github.com/MixinNetwork/flutter-plugins/tree/main/packages/desktop_drop

environment:
Expand Down
Loading