Skip to content

🔧 - Migrate zstandardandroid plugin from KGP to builtin Kotlin #142

Description

@maximilianoe

Is there an existing issue for this?

  • I have searched the existing issues.

What area does this task affect?

Zstandard Android

Task description

I am using zstandard_android in my Flutter app.

Starting with Android Gradle Plugin (AGP) 9.0,
support for applying the Kotlin Gradle Plugin (KGP) has been removed.
Because this plugin applies KGP,
it causes a compilation error that prevents my app from building.
Flutter issue #181383
includes an example of the error.

Flutter has temporarily added support to allow KGP
while apps and plugins migrate to AGP 9.0 or later,
but this support will be removed in a future version of Flutter.

Please migrate this plugin to use built-in Kotlin to
ensure your plugin users can successfully
build their apps in future versions of Flutter.

Here is the Flutter
migration guide for plugin authors.

Current issues or inefficiencies

Kotlin Gradle Plugin (KGP) instead of Built-in Kotlin is used.

Expected impact

Future versions of Flutter will deprecate Kotlin Gradle Plugin (KGP), apps using zstandard_android will fail to build.

Alternatives considered

No response

Additional context or comments

No response

Activity

  1. changed the title [-]Migrate zstandard_android plugin from KGP to built-in Kotlin[/-] [+]🔧 - Migrate zstandardandroid plugin from KGP to builtin Kotlin[/+] on Aug 14, 2026
  2. moved this to Todo in vypdevon Aug 14, 2026
  3. vypbot commented on Aug 14, 2026

    @vypbot
    Contributor

    🪄 Automatic Actions

    1. The issue was assigned to @efraespada.
    2. The issue's title was updated from Migrate zstandard_android plugin from KGP to built-in Kotlin to 🔧 - Migrate zstandardandroid plugin from KGP to builtin Kotlin.
    3. The issue was linked to vypdev and moved to the column Todo.
    4. Priority set to P2 in vypdev.
    5. Recommended steps (OpenCode Plan agent):
    6. Based on my review of the repo, the issue is confirmed: zstandard_android/android/build.gradle:28 applies kotlin-android unconditionally, declares KGP on the buildscript classpath (:16), and uses kotlinOptions (:60-62). The example apps (zstandard_android/example and zstandard/example) also apply KGP. This breaks builds under AGP 9.0+, which removes KGP support.

    Below are the recommended implementation steps, following Flutter's migration guide for plugin authors.


    Migrate zstandard_android to built-in Kotlin (AGP 9+)

    1. Confirm the current state and choose a migration path

    • Verify KGP usage (already confirmed):
      • zstandard_android/android/build.gradle:16 — classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
      • zstandard_android/android/build.gradle:28 — apply plugin: "kotlin-android"
      • zstandard_android/android/build.gradle:60-62 — kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8 }
    • Decide between two paths from the Flutter guide:
      • A (recommended): Conditional KGP — apply KGP only when AGP < 9; use built-in Kotlin on AGP >= 9. Backward compatible with existing AGP 8 users.
      • B (simpler): Require AGP 9 — drop KGP entirely. Cleanest, but forces all consumers onto AGP 9+.
    • This repo targets a broad user base and keeps a low Flutter minimum, so Option A is the safer choice. Steps below follow Option A.

    2. Update zstandard_android/android/build.gradle (core fix)

    Apply the plugin conditionally and replace kotlinOptions with the modern compilerOptions DSL. Keep everything else (NDK, CMake, minSdk) unchanged.

    apply plugin: "com.android.library"
    
    // AGP 9.0+ provides built-in Kotlin and no longer supports applying the
    // Kotlin Gradle Plugin. Only apply KGP when the consumer's AGP is older.
    def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int
    if (agpMajor < 9) {
        apply plugin: 'kotlin-android'
    }
    
    android {
        // ... existing content unchanged (namespace, compileSdk, ndkVersion,
        //     externalNativeBuild, sourceSets, compileOptions, defaultConfig) ...
    
        // REMOVE the old kotlinOptions block (lines 60-62)
    }
    
    kotlin {
        compilerOptions {
            jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
        }
    }
    
    dependencies {
        // ... unchanged ...
    }

    Also update the buildscript block:

    • Bump KGP to 2.0.0 or later (ext.kotlin_version = "2.1.0") — the compilerOptions DSL requires KGP 2.0+, and this version is what the AGP < 9 fallback path needs.
    • Keep (or bump to 9.x) the AGP classpath so the plugin still builds standalone and to exercise the AGP 9 path in tests.
    • Add a short comment above the new kotlin {} block noting it mirrors kotlinOptions at JVM_1_8 to match the compileOptions (JVM 17 is only needed if you also raise compileOptions).

    3. Bump minimum Flutter/Dart versions in pubspec.yaml

    Per the guide, the kotlin { compilerOptions {} } DSL requires KGP 2.0.0, which only arrives with Flutter 3.44. Update zstandard_android/pubspec.yaml:8-10:

    environment:
      sdk: ^3.12.0
      flutter: '>=3.44.0'
    • Also bump the dependent package versions so the constraint resolves correctly. The repo centralizes versions (see docs/development/release-process.md), so plan a MINOR release (e.g. 1.6.0) across zstandard_android, zstandard (which depends on zstandard_android), and the other federated packages so pub can resolve the new minimums.

    4. Migrate the example apps (app-developers migration)

    Both example apps still apply KGP and must be migrated, since the plugin's own build is exercised through them:

    zstandard_android/example/android/settings.gradle:19-23 — bump AGP to 9.x and drop the KGP plugin declaration:

    plugins {
        id "dev.flutter.flutter-plugin-loader" version "1.0.0"
        id "com.android.application" version "9.0.0" apply false
    }

    zstandard_android/example/android/app/build.gradle:1-6 — remove id "kotlin-android" and the kotlinOptions block (:18-20); add the kotlin.compilerOptions {} block if you need to pin the target:

    plugins {
        id "com.android.application"
        // The Flutter Gradle Plugin must be applied after the Android Gradle plugin.
        id "dev.flutter.flutter-gradle-plugin"
    }
    
    kotlin {
        compilerOptions {
            jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
        }
    }

    zstandard_android/example/android/gradle.properties — add to enable/validate built-in Kotlin (requires Flutter 3.47+):

    android.builtInKotlin=true

    Apply the same four changes to zstandard/example/android/ (settings.gradle, app/build.gradle, build.gradle, gradle.properties) since the main package's example also applies KGP.

    5. Update the CHANGELOG

    Add an entry at the top of zstandard_android/CHANGELOG.md (and the root CHANGELOG.md, which is copied per package on release):

    ## 1.6.0 - Built-in Kotlin
    
    - Migrated to built-in Kotlin for AGP 9.0+ compatibility.
    - Applies the Kotlin Gradle Plugin only when the consumer's AGP is older than 9.
    - Updates the minimum supported SDK to Flutter 3.44 / Dart 3.12.

    6. Validate locally

    • flutter analyze in zstandard_android and zstandard.
    • flutter test in zstandard_android (unit tests).
    • From zstandard_android/example, run the integration tests on an emulator:
      flutter test integration_test/ -d emulator-5554
      or a plain build sanity check:
      flutter build apk --debug
    • Test both code paths:
      1. AGP 9 + built-in Kotlin: run the example with AGP 9.x, android.builtInKotlin=true, on Flutter 3.47+.
      2. Backward compat (AGP 8 + KGP): run the example with AGP 8.x and KGP 2.0+ to confirm the conditional branch still applies KGP and builds.

    7. Update CI

    pr_check_android.yml currently pins FLUTTER_VERSION: '3.41.4' (:14), which predates the changes. Update it to 3.47+ (or add a version matrix covering both the old and new Flutter/AGP combos) so the emulator integration tests in that workflow exercise the migrated build. Keep the pub-cache variant (check_android_test_from_pub_cache) as-is.

    8. Documentation

    • Add a short "Requirements" note to docs/platforms/android.md mentioning that zstandard_android 1.6.0+ requires Flutter 3.44+ and works with both AGP 8 (via KGP) and AGP 9+ (built-in Kotlin).
    • If the README's compatibility tables ever list Kotlin/Gradle specifics, note the AGP 9.0 requirement there too.

    Notes / caveats

    • The plugin's own build.gradle buildscript block only affects standalone/Android-Studio builds; when consumed by an app, the app's AGP/KGP classpath governs the agpMajor check, which is exactly what the conditional logic keys on.
    • Keep jvmTarget aligned with compileOptions (1.8); only bump to JVM_17 if you also raise compileOptions, which is a larger breaking change and not required for this issue.
    • Ship the version bump as one release across all federated packages so pub.dev resolves the new zstandard_android minimum consistently with zstandard.

    image

    Debug log
    [DEBUG] Setup done. Issue number: 142, isSingleAction: false, isIssue: true, isPullRequest: false, isPush: false
    [DEBUG] ✅ No previous runs active. Continuing...
    [INFO] Running IssueUseCase for issue #142.
    [INFO] 📋 Executing IssueUseCase.
    [INFO] 🔐 Executing CheckPermissionsUseCase.
    [DEBUG] Ignoring permission checking. Issue doesn't require mandatory branch.
    [INFO] 👤 Executing AssignMemberToIssueUseCase.
    [DEBUG] #142 needs 1 assignees.
    [DEBUG] Checking team: tatooine
    [DEBUG] Members: 2
    [INFO] ✏️ Executing UpdateTitleUseCase.
    [DEBUG] Issue title updated to: 🔧 - Migrate zstandardandroid plugin from KGP to builtin Kotlin
    [INFO] 🏷️ Executing UpdateIssueTypeUseCase.
    [DEBUG] Setting issue type for issue 142 to Maintenance
    [DEBUG] Creating new issue type "Maintenance" for organization vypdev...
    [DEBUG] Issue Type: Maintenance
    [DEBUG] Issue Type Description: A task related to refactoring, dependency updates, or other technical maintenance work.
    [DEBUG] Issue Type Color: purple
    [DEBUG] Fetched issue ID: I_kwDONFe3188AAAABMs6nWQ
    [DEBUG] Organization ID: MDEyOk9yZ2FuaXphdGlvbjYzNzA1NDAz
    [DEBUG] Organization issue types: [{"id":"IT_kwDOA8wRO84AuWac","name":"Task"},{"id":"IT_kwDOA8wRO84AuWag","name":"Bug"},{"id":"IT_kwDOA8wRO84AuWak","name":"Feature"},{"id":"IT_kwDOA8wRO84Bw9l2","name":"Documentation"},{"id":"IT_kwDOA8wRO84Bw9mw","name":"Question"},{"id":"IT_kwDOA8wRO84Bw9oA","name":"Maintenance"},{"id":"IT_kwDOA8wRO84Bw90_","name":"Release"},{"id":"IT_kwDOA8wRO84Bxfgg","name":"Hotfix"},{"id":"IT_kwDOA8wRO84Bxfgh","name":"Help"}]
    [DEBUG] Found existing issue type "Maintenance" with ID: IT_kwDOA8wRO84Bw9oA
    [DEBUG] Successfully updated issue type to Maintenance
    [INFO] 🔗 Executing LinkIssueProjectUseCase.
    [DEBUG] Fetched issue ID: I_kwDONFe3188AAAABMs6nWQ
    [DEBUG] Linked I_kwDONFe3188AAAABMs6nWQ with id PVTI_lADOA8wRO84Ajh7Bzg2ey5E to project PVT_kwDOA8wRO84Ajh7B
    [DEBUG] Content ID: PVTI_lADOA8wRO84Ajh7Bzg2ey5E
    [DEBUG] Target field: {
      "id": "PVTSSF_lADOA8wRO84Ajh7Bzgb4L2E",
      "name": "Status",
      "options": [
        {
          "id": "f75ad846",
          "name": "Todo"
        },
        {
          "id": "47fc9ee4",
          "name": "In Progress"
        },
        {
          "id": "98236657",
          "name": "Done"
        }
      ]
    }
    [DEBUG] Target option: {
      "id": "f75ad846",
      "name": "Todo"
    }
    [DEBUG] Target field ID: PVTSSF_lADOA8wRO84Ajh7Bzgb4L2E
    [DEBUG] Target option ID: f75ad846
    [INFO] 📏 Executing CheckPriorityIssueSizeUseCase.
    [DEBUG] Priority: priority: low
    [DEBUG] Github Priority Label: P2
    [DEBUG] Content ID: PVTI_lADOA8wRO84Ajh7Bzg2ey5E
    [DEBUG] Target field: {
      "id": "PVTSSF_lADOA8wRO84Ajh7Bzgb4MPQ",
      "name": "Priority",
      "options": [
        {
          "id": "4af6496f",
          "name": "P0"
        },
        {
          "id": "f87877a5",
          "name": "P1"
        },
        {
          "id": "27f99ddc",
          "name": "P2"
        }
      ]
    }
    [DEBUG] Target option: {
      "id": "27f99ddc",
      "name": "P2"
    }
    [DEBUG] Target field ID: PVTSSF_lADOA8wRO84Ajh7Bzgb4MPQ
    [DEBUG] Target option ID: 27f99ddc
    [INFO] 🧹 Executing RemoveIssueBranchesUseCase.
    [DEBUG] Checking branch type feature
    [DEBUG] Checking prefix feature/142-
    [DEBUG] Checking branch type bugfix
    [DEBUG] Checking prefix bugfix/142-
    [INFO] 🧹 Executing RemoveNotNeededBranchesUseCase.
    [INFO] 🏷️ Executing DeployAddedUseCase.
    [INFO] 🏷️ Executing DeployedAddedUseCase.
    [INFO] 💡 Executing RecommendStepsUseCase.
    [DEBUG] RecommendSteps: prompt length=2188, issue description length=1350.
    [INFO] 🤖 Recommending steps using OpenCode Plan agent...
    [INFO] OpenCode request [agent build] model=opencode/deepseek-v4-flash-free promptLength=2188
    [INFO] OpenCode sending prompt (full):
    Based on the following issue description, recommend concrete steps to implement or address this issue. Order the steps logically (e.g. setup, implementation, tests, docs). Keep each step clear and actionable.
    
    **Important – use full project context:** In addition to reading the relevant code (respecting any file ignore patterns specified), read the repository documentation (e.g. README, docs/) and any defined rules or conventions (e.g. .cursor/rules, CONTRIBUTING, project guidelines). This gives you a complete picture of the project and leads to better decisions in both quality of reasoning and efficiency.
    
    **Issue #142 description:**
    ### Is there an existing issue for this?
    
    - [x] I have searched the existing issues.
    
    ### What area does this task affect?
    
    Zstandard Android
    
    ### Task description
    
    I am using `zstandard_android ` in my Flutter app.
    
    Starting with Android Gradle Plugin (AGP) 9.0,
    support for applying the Kotlin Gradle Plugin (KGP) has been removed.
    Because this plugin applies KGP,
    it causes a compilation error that prevents my app from building.
    Flutter [issue #181383](https://github.com/flutter/flutter/issues/181383)
    includes an example of the error.
    
    Flutter has temporarily added support to allow KGP
    while apps and plugins migrate to AGP 9.0 or later,
    but this support will be removed in a future version of Flutter.
    
    Please migrate this plugin to use built-in Kotlin to
    ensure your plugin users can successfully
    build their apps in future versions of Flutter.
    
    Here is the Flutter
    [migration guide for plugin authors](https://docs.flutter.dev/release/breaking-changes/migrate-to-built-in-kotlin/for-plugin-authors).
    
    ### Current issues or inefficiencies
    
    Kotlin Gradle Plugin (KGP) instead of Built-in Kotlin is used.
    
    ### Expected impact
    
    Future versions of Flutter will deprecate Kotlin Gradle Plugin (KGP), apps using `zstandard_android ` will fail to build.
    
    ### Alternatives considered
    
    _No response_
    
    ### Additional context or comments
    
    _No response_
    
    Provide a numbered list of recommended steps in **markdown** (use headings, lists, code blocks for commands or snippets) so it is easy to read. You can add brief sub-bullets per step if needed.
    [DEBUG] OpenCode prompt (full, no truncation):
    Based on the following issue description, recommend concrete steps to implement or address this issue. Order the steps logically (e.g. setup, implementation, tests, docs). Keep each step clear and actionable.
    
    **Important – use full project context:** In addition to reading the relevant code (respecting any file ignore patterns specified), read the repository documentation (e.g. README, docs/) and any defined rules or conventions (e.g. .cursor/rules, CONTRIBUTING, project guidelines). This gives you a complete picture of the project and leads to better decisions in both quality of reasoning and efficiency.
    
    **Issue #142 description:**
    ### Is there an existing issue for this?
    
    - [x] I have searched the existing issues.
    
    ### What area does this task affect?
    
    Zstandard Android
    
    ### Task description
    
    I am using `zstandard_android ` in my Flutter app.
    
    Starting with Android Gradle Plugin (AGP) 9.0,
    support for applying the Kotlin Gradle Plugin (KGP) has been removed.
    Because this plugin applies KGP,
    it causes a compilation error that prevents my app from building.
    Flutter [issue #181383](https://github.com/flutter/flutter/issues/181383)
    includes an example of the error.
    
    Flutter has temporarily added support to allow KGP
    while apps and plugins migrate to AGP 9.0 or later,
    but this support will be removed in a future version of Flutter.
    
    Please migrate this plugin to use built-in Kotlin to
    ensure your plugin users can successfully
    build their apps in future versions of Flutter.
    
    Here is the Flutter
    [migration guide for plugin authors](https://docs.flutter.dev/release/breaking-changes/migrate-to-built-in-kotlin/for-plugin-authors).
    
    ### Current issues or inefficiencies
    
    Kotlin Gradle Plugin (KGP) instead of Built-in Kotlin is used.
    
    ### Expected impact
    
    Future versions of Flutter will deprecate Kotlin Gradle Plugin (KGP), apps using `zstandard_android ` will fail to build.
    
    ### Alternatives considered
    
    _No response_
    
    ### Additional context or comments
    
    _No response_
    
    Provide a numbered list of recommended steps in **markdown** (use headings, lists, code blocks for commands or snippets) so it is easy to read. You can add brief sub-bullets per step if needed.
    [DEBUG] OpenCode message body: agent=build, model=opencode/deepseek-v4-flash-free, parts[0].text length=2188
    [DEBUG] OpenCode session create body: {"title":"copilot"}
    [DEBUG] OpenCode response [OpenCode session.create] status=200 bodyLength=357. Full body:
    {"id":"ses_0020f48b3ffexZ6edT3aBxzOMO","slug":"quiet-rocket","projectID":"4ac61bfddbc238ba0b5af83ff818f3c45e41faf8","directory":"/home/runner/work/zstandard/zstandard","path":"","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}},"title":"copilot","version":"1.18.18","time":{"created":1786671839053,"updated":1786671839053}}
    [DEBUG] OpenCode POST /session/ses_0020f48b3ffexZ6edT3aBxzOMO/message body (keys): agent, model, parts (1 part(s))
    [INFO] OpenCode: waiting for agent "build" message response (client timeout: 15 min)...
    [DEBUG] OpenCode response [OpenCode agent "build" message] status=200 bodyLength=9640. Full body:
    {"info":{"parentID":"msg_ffdf0b77f001WkzF5c94lR7AH7","role":"assistant","mode":"build","agent":"build","path":{"cwd":"/home/runner/work/zstandard/zstandard","root":"/home/runner/work/zstandard/zstandard"},"cost":0,"tokens":{"total":53943,"input":1540,"output":2227,"reasoning":0,"cache":{"write":0,"read":50176}},"modelID":"deepseek-v4-flash-free","providerID":"opencode","time":{"created":1786671977403,"completed":1786672034859},"finish":"stop","id":"msg_ffdf2d3bb001paPvKvHyLpObi3","sessionID":"ses_0020f48b3ffexZ6edT3aBxzOMO"},"parts":[{"snapshot":"d88dd86112768d34fab7e335fe13024c3ff3f561","type":"step-start","id":"prt_ffdf368e6001rV43PKWmdMLEVA","sessionID":"ses_0020f48b3ffexZ6edT3aBxzOMO","messageID":"msg_ffdf2d3bb001paPvKvHyLpObi3"},{"type":"reasoning","text":"I have a complete picture now. Let me write the recommended steps. This is a documentation/recommendation task, not an implementation task. I'll provide a numbered list of markdown steps with headings, code blocks, and sub-bullets.\n\nLet me be thorough but concise. I'll structure:\n\n1. Understand the current state & confirm migration path\n2. Update `zstandard_android/android/build.gradle` (core fix)\n3. Bump minimum Flutter/Dart in pubspec.yaml\n4. Migrate example app(s)\n5. Update CHANGELOG + version bump\n6. Validate locally\n7. Update CI\n8. Documentation\n\nI'll present the primary path (conditional KGP, backward compatible) with full code, and mention the simpler option.\n\nLet me write it out.","time":{"start":1786672015593,"end":1786672016478},"id":"prt_ffdf368e9001cW8X4MDvu2YL1W","sessionID":"ses_0020f48b3ffexZ6edT3aBxzOMO","messageID":"msg_ffdf2d3bb001paPvKvHyLpObi3"},{"type":"text","text":"Based on my review of the repo, the issue is confirmed: `zstandard_android/android/build.gradle:28` applies `kotlin-android` unconditionally, declares KGP on the buildscript classpath (`:16`), and uses `kotlinOptions` (`:60-62`). The example apps (`zstandard_android/example` and `zstandard/example`) also apply KGP. This breaks builds under AGP 9.0+, which removes KGP support.\n\nBelow are the recommended implementation steps, following Flutter's [migration guide for plugin authors](https://docs.flutter.dev/release/breaking-changes/migrate-to-built-in-kotlin/for-plugin-authors).\n\n---\n\n# Migrate `zstandard_android` to built-in Kotlin (AGP 9+)\n\n## 1. Confirm the current state and choose a migration path\n\n- Verify KGP usage (already confirmed):\n  - `zstandard_android/android/build.gradle:16` — `classpath(\"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version\")`\n  - `zstandard_android/android/build.gradle:28` — `apply plugin: \"kotlin-android\"`\n  - `zstandard_android/android/build.gradle:60-62` — `kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8 }`\n- Decide between two paths from the Flutter guide:\n  - **A (recommended): Conditional KGP** — apply KGP only when AGP `< 9`; use built-in Kotlin on AGP `>= 9`. Backward compatible with existing AGP 8 users.\n  - **B (simpler): Require AGP 9** — drop KGP entirely. Cleanest, but forces all consumers onto AGP 9+.\n- This repo targets a broad user base and keeps a low Flutter minimum, so **Option A** is the safer choice. Steps below follow Option A.\n\n## 2. Update `zstandard_android/android/build.gradle` (core fix)\n\nApply the plugin conditionally and replace `kotlinOptions` with the modern `compilerOptions` DSL. Keep everything else (NDK, CMake, minSdk) unchanged.\n\ngroovy\napply plugin: \"com.android.library\"\n\n// AGP 9.0+ provides built-in Kotlin and no longer supports applying the\n// Kotlin Gradle Plugin. Only apply KGP when the consumer's AGP is older.\ndef agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int\nif (agpMajor < 9) {\n    apply plugin: 'kotlin-android'\n}\n\nandroid {\n    // ... existing content unchanged (namespace, compileSdk, ndkVersion,\n    //     externalNativeBuild, sourceSets, compileOptions, defaultConfig) ...\n\n    // REMOVE the old kotlinOptions block (lines 60-62)\n}\n\nkotlin {\n    compilerOptions {\n        jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8\n    }\n}\n\ndependencies {\n    // ... unchanged ...\n}\n\n\nAlso update the `buildscript` block:\n- Bump KGP to `2.0.0` or later (`ext.kotlin_version = \"2.1.0\"`) — the `compilerOptions` DSL requires KGP 2.0+, and this version is what the AGP `< 9` fallback path needs.\n- Keep (or bump to `9.x`) the AGP classpath so the plugin still builds standalone and to exercise the AGP 9 path in tests.\n- Add a short comment above the new `kotlin {}` block noting it mirrors `kotlinOptions` at `JVM_1_8` to match the `compileOptions` (JVM 17 is only needed if you also raise `compileOptions`).\n\n## 3. Bump minimum Flutter/Dart versions in `pubspec.yaml`\n\nPer the guide, the `kotlin { compilerOptions {} }` DSL requires KGP 2.0.0, which only arrives with Flutter 3.44. Update `zstandard_android/pubspec.yaml:8-10`:\n\nyaml\nenvironment:\n  sdk: ^3.12.0\n  flutter: '>=3.44.0'\n\n\n- Also bump the dependent package versions so the constraint resolves correctly. The repo centralizes versions (see `docs/development/release-process.md`), so plan a **MINOR** release (e.g. `1.6.0`) across `zstandard_android`, `zstandard` (which depends on `zstandard_android`), and the other federated packages so pub can resolve the new minimums.\n\n## 4. Migrate the example apps (app-developers migration)\n\nBoth example apps still apply KGP and must be migrated, since the plugin's own build is exercised through them:\n\n**`zstandard_android/example/android/settings.gradle:19-23`** — bump AGP to `9.x` and drop the KGP plugin declaration:\ngradle\nplugins {\n    id \"dev.flutter.flutter-plugin-loader\" version \"1.0.0\"\n    id \"com.android.application\" version \"9.0.0\" apply false\n}\n\n\n**`zstandard_android/example/android/app/build.gradle:1-6`** — remove `id \"kotlin-android\"` and the `kotlinOptions` block (`:18-20`); add the `kotlin.compilerOptions {}` block if you need to pin the target:\ngradle\nplugins {\n    id \"com.android.application\"\n    // The Flutter Gradle Plugin must be applied after the Android Gradle plugin.\n    id \"dev.flutter.flutter-gradle-plugin\"\n}\n\nkotlin {\n    compilerOptions {\n        jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17\n    }\n}\n\n\n**`zstandard_android/example/android/gradle.properties`** — add to enable/validate built-in Kotlin (requires Flutter 3.47+):\nproperties\nandroid.builtInKotlin=true\n\n\nApply the same four changes to `zstandard/example/android/` (`settings.gradle`, `app/build.gradle`, `build.gradle`, `gradle.properties`) since the main package's example also applies KGP.\n\n## 5. Update the CHANGELOG\n\nAdd an entry at the top of `zstandard_android/CHANGELOG.md` (and the root `CHANGELOG.md`, which is copied per package on release):\n\nmarkdown\n## 1.6.0 - Built-in Kotlin\n\n- Migrated to built-in Kotlin for AGP 9.0+ compatibility.\n- Applies the Kotlin Gradle Plugin only when the consumer's AGP is older than 9.\n- Updates the minimum supported SDK to Flutter 3.44 / Dart 3.12.\n\n\n## 6. Validate locally\n\n- `flutter analyze` in `zstandard_android` and `zstandard`.\n- `flutter test` in `zstandard_android` (unit tests).\n- From `zstandard_android/example`, run the integration tests on an emulator:\n  bash\n  flutter test integration_test/ -d emulator-5554\n  \n  or a plain build sanity check:\n  bash\n  flutter build apk --debug\n  \n- **Test both code paths**:\n  1. **AGP 9 + built-in Kotlin**: run the example with AGP `9.x`, `android.builtInKotlin=true`, on Flutter `3.47+`.\n  2. **Backward compat (AGP 8 + KGP)**: run the example with AGP `8.x` and KGP `2.0+` to confirm the conditional branch still applies KGP and builds.\n\n## 7. Update CI\n\n`pr_check_android.yml` currently pins `FLUTTER_VERSION: '3.41.4'` (`:14`), which predates the changes. Update it to `3.47`+ (or add a version matrix covering both the old and new Flutter/AGP combos) so the emulator integration tests in that workflow exercise the migrated build. Keep the pub-cache variant (`check_android_test_from_pub_cache`) as-is.\n\n## 8. Documentation\n\n- Add a short \"Requirements\" note to `docs/platforms/android.md` mentioning that `zstandard_android` 1.6.0+ requires Flutter 3.44+ and works with both AGP 8 (via KGP) and AGP 9+ (built-in Kotlin).\n- If the README's compatibility tables ever list Kotlin/Gradle specifics, note the AGP 9.0 requirement there too.\n\n---\n\n**Notes / caveats**\n- The plugin's own `build.gradle` `buildscript` block only affects standalone/Android-Studio builds; when consumed by an app, the app's AGP/KGP classpath governs the `agpMajor` check, which is exactly what the conditional logic keys on.\n- Keep `jvmTarget` aligned with `compileOptions` (`1.8`); only bump to `JVM_17` if you also raise `compileOptions`, which is a larger breaking change and not required for this issue.\n- Ship the version bump as one release across all federated packages so pub.dev resolves the new `zstandard_android` minimum consistently with `zstandard`.","time":{"start":1786672016480,"end":1786672034805},"id":"prt_ffdf36c60001dK5IuDbR0R1KIn","sessionID":"ses_0020f48b3ffexZ6edT3aBxzOMO","messageID":"msg_ffdf2d3bb001paPvKvHyLpObi3"},{"reason":"stop","snapshot":"d88dd86112768d34fab7e335fe13024c3ff3f561","type":"step-finish","tokens":{"total":53943,"input":1540,"output":2227,"reasoning":0,"cache":{"write":0,"read":50176}},"cost":0,"id":"prt_ffdf3b4140013RZfBkgZDZ4sTT","sessionID":"ses_0020f48b3ffexZ6edT3aBxzOMO","messageID":"msg_ffdf2d3bb001paPvKvHyLpObi3"}]}
    [DEBUG] OpenCode agent "build" message parts: 4 part(s) — [0] type=step-start length=0 | [1] type=reasoning length=696 | [2] type=text length=7272 | [3] type=step-finish length=0
    [DEBUG] OpenCode part [1] type=reasoning full text:
    I have a complete picture now. Let me write the recommended steps. This is a documentation/recommendation task, not an implementation task. I'll provide a numbered list of markdown steps with headings, code blocks, and sub-bullets.
    
    Let me be thorough but concise. I'll structure:
    
    1. Understand the current state & confirm migration path
    2. Update `zstandard_android/android/build.gradle` (core fix)
    3. Bump minimum Flutter/Dart in pubspec.yaml
    4. Migrate example app(s)
    5. Update CHANGELOG + version bump
    6. Validate locally
    7. Update CI
    8. Documentation
    
    I'll present the primary path (conditional KGP, backward compatible) with full code, and mention the simpler option.
    
    Let me write it out.
    [DEBUG] OpenCode part [2] type=text full text:
    Based on my review of the repo, the issue is confirmed: `zstandard_android/android/build.gradle:28` applies `kotlin-android` unconditionally, declares KGP on the buildscript classpath (`:16`), and uses `kotlinOptions` (`:60-62`). The example apps (`zstandard_android/example` and `zstandard/example`) also apply KGP. This breaks builds under AGP 9.0+, which removes KGP support.
    
    Below are the recommended implementation steps, following Flutter's [migration guide for plugin authors](https://docs.flutter.dev/release/breaking-changes/migrate-to-built-in-kotlin/for-plugin-authors).
    
    ---
    
    # Migrate `zstandard_android` to built-in Kotlin (AGP 9+)
    
    ## 1. Confirm the current state and choose a migration path
    
    - Verify KGP usage (already confirmed):
      - `zstandard_android/android/build.gradle:16` — `classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")`
      - `zstandard_android/android/build.gradle:28` — `apply plugin: "kotlin-android"`
      - `zstandard_android/android/build.gradle:60-62` — `kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8 }`
    - Decide between two paths from the Flutter guide:
      - **A (recommended): Conditional KGP** — apply KGP only when AGP `< 9`; use built-in Kotlin on AGP `>= 9`. Backward compatible with existing AGP 8 users.
      - **B (simpler): Require AGP 9** — drop KGP entirely. Cleanest, but forces all consumers onto AGP 9+.
    - This repo targets a broad user base and keeps a low Flutter minimum, so **Option A** is the safer choice. Steps below follow Option A.
    
    ## 2. Update `zstandard_android/android/build.gradle` (core fix)
    
    Apply the plugin conditionally and replace `kotlinOptions` with the modern `compilerOptions` DSL. Keep everything else (NDK, CMake, minSdk) unchanged.
    
    groovy
    apply plugin: "com.android.library"
    
    // AGP 9.0+ provides built-in Kotlin and no longer supports applying the
    // Kotlin Gradle Plugin. Only apply KGP when the consumer's AGP is older.
    def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int
    if (agpMajor < 9) {
        apply plugin: 'kotlin-android'
    }
    
    android {
        // ... existing content unchanged (namespace, compileSdk, ndkVersion,
        //     externalNativeBuild, sourceSets, compileOptions, defaultConfig) ...
    
        // REMOVE the old kotlinOptions block (lines 60-62)
    }
    
    kotlin {
        compilerOptions {
            jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
        }
    }
    
    dependencies {
        // ... unchanged ...
    }
    
    
    Also update the `buildscript` block:
    - Bump KGP to `2.0.0` or later (`ext.kotlin_version = "2.1.0"`) — the `compilerOptions` DSL requires KGP 2.0+, and this version is what the AGP `< 9` fallback path needs.
    - Keep (or bump to `9.x`) the AGP classpath so the plugin still builds standalone and to exercise the AGP 9 path in tests.
    - Add a short comment above the new `kotlin {}` block noting it mirrors `kotlinOptions` at `JVM_1_8` to match the `compileOptions` (JVM 17 is only needed if you also raise `compileOptions`).
    
    ## 3. Bump minimum Flutter/Dart versions in `pubspec.yaml`
    
    Per the guide, the `kotlin { compilerOptions {} }` DSL requires KGP 2.0.0, which only arrives with Flutter 3.44. Update `zstandard_android/pubspec.yaml:8-10`:
    
    yaml
    environment:
      sdk: ^3.12.0
      flutter: '>=3.44.0'
    
    
    - Also bump the dependent package versions so the constraint resolves correctly. The repo centralizes versions (see `docs/development/release-process.md`), so plan a **MINOR** release (e.g. `1.6.0`) across `zstandard_android`, `zstandard` (which depends on `zstandard_android`), and the other federated packages so pub can resolve the new minimums.
    
    ## 4. Migrate the example apps (app-developers migration)
    
    Both example apps still apply KGP and must be migrated, since the plugin's own build is exercised through them:
    
    **`zstandard_android/example/android/settings.gradle:19-23`** — bump AGP to `9.x` and drop the KGP plugin declaration:
    gradle
    plugins {
        id "dev.flutter.flutter-plugin-loader" version "1.0.0"
        id "com.android.application" version "9.0.0" apply false
    }
    
    
    **`zstandard_android/example/android/app/build.gradle:1-6`** — remove `id "kotlin-android"` and the `kotlinOptions` block (`:18-20`); add the `kotlin.compilerOptions {}` block if you need to pin the target:
    gradle
    plugins {
        id "com.android.application"
        // The Flutter Gradle Plugin must be applied after the Android Gradle plugin.
        id "dev.flutter.flutter-gradle-plugin"
    }
    
    kotlin {
        compilerOptions {
            jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
        }
    }
    
    
    **`zstandard_android/example/android/gradle.properties`** — add to enable/validate built-in Kotlin (requires Flutter 3.47+):
    properties
    android.builtInKotlin=true
    
    
    Apply the same four changes to `zstandard/example/android/` (`settings.gradle`, `app/build.gradle`, `build.gradle`, `gradle.properties`) since the main package's example also applies KGP.
    
    ## 5. Update the CHANGELOG
    
    Add an entry at the top of `zstandard_android/CHANGELOG.md` (and the root `CHANGELOG.md`, which is copied per package on release):
    
    markdown
    ## 1.6.0 - Built-in Kotlin
    
    - Migrated to built-in Kotlin for AGP 9.0+ compatibility.
    - Applies the Kotlin Gradle Plugin only when the consumer's AGP is older than 9.
    - Updates the minimum supported SDK to Flutter 3.44 / Dart 3.12.
    
    
    ## 6. Validate locally
    
    - `flutter analyze` in `zstandard_android` and `zstandard`.
    - `flutter test` in `zstandard_android` (unit tests).
    - From `zstandard_android/example`, run the integration tests on an emulator:
      bash
      flutter test integration_test/ -d emulator-5554
      
      or a plain build sanity check:
      bash
      flutter build apk --debug
      
    - **Test both code paths**:
      1. **AGP 9 + built-in Kotlin**: run the example with AGP `9.x`, `android.builtInKotlin=true`, on Flutter `3.47+`.
      2. **Backward compat (AGP 8 + KGP)**: run the example with AGP `8.x` and KGP `2.0+` to confirm the conditional branch still applies KGP and builds.
    
    ## 7. Update CI
    
    `pr_check_android.yml` currently pins `FLUTTER_VERSION: '3.41.4'` (`:14`), which predates the changes. Update it to `3.47`+ (or add a version matrix covering both the old and new Flutter/AGP combos) so the emulator integration tests in that workflow exercise the migrated build. Keep the pub-cache variant (`check_android_test_from_pub_cache`) as-is.
    
    ## 8. Documentation
    
    - Add a short "Requirements" note to `docs/platforms/android.md` mentioning that `zstandard_android` 1.6.0+ requires Flutter 3.44+ and works with both AGP 8 (via KGP) and AGP 9+ (built-in Kotlin).
    - If the README's compatibility tables ever list Kotlin/Gradle specifics, note the AGP 9.0 requirement there too.
    
    ---
    
    **Notes / caveats**
    - The plugin's own `build.gradle` `buildscript` block only affects standalone/Android-Studio builds; when consumed by an app, the app's AGP/KGP classpath governs the `agpMajor` check, which is exactly what the conditional logic keys on.
    - Keep `jvmTarget` aligned with `compileOptions` (`1.8`); only bump to `JVM_17` if you also raise `compileOptions`, which is a larger breaking change and not required for this issue.
    - Ship the version bump as one release across all federated packages so pub.dev resolves the new `zstandard_android` minimum consistently with `zstandard`.
    [INFO] OpenCode response [agent build] responseLength=7272 sessionId=ses_0020f48b3ffexZ6edT3aBxzOMO
    [DEBUG] RecommendSteps: OpenCode response received. Steps length=7272. Full steps:
    Based on my review of the repo, the issue is confirmed: `zstandard_android/android/build.gradle:28` applies `kotlin-android` unconditionally, declares KGP on the buildscript classpath (`:16`), and uses `kotlinOptions` (`:60-62`). The example apps (`zstandard_android/example` and `zstandard/example`) also apply KGP. This breaks builds under AGP 9.0+, which removes KGP support.
    
    Below are the recommended implementation steps, following Flutter's [migration guide for plugin authors](https://docs.flutter.dev/release/breaking-changes/migrate-to-built-in-kotlin/for-plugin-authors).
    
    ---
    
    # Migrate `zstandard_android` to built-in Kotlin (AGP 9+)
    
    ## 1. Confirm the current state and choose a migration path
    
    - Verify KGP usage (already confirmed):
      - `zstandard_android/android/build.gradle:16` — `classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")`
      - `zstandard_android/android/build.gradle:28` — `apply plugin: "kotlin-android"`
      - `zstandard_android/android/build.gradle:60-62` — `kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8 }`
    - Decide between two paths from the Flutter guide:
      - **A (recommended): Conditional KGP** — apply KGP only when AGP `< 9`; use built-in Kotlin on AGP `>= 9`. Backward compatible with existing AGP 8 users.
      - **B (simpler): Require AGP 9** — drop KGP entirely. Cleanest, but forces all consumers onto AGP 9+.
    - This repo targets a broad user base and keeps a low Flutter minimum, so **Option A** is the safer choice. Steps below follow Option A.
    
    ## 2. Update `zstandard_android/android/build.gradle` (core fix)
    
    Apply the plugin conditionally and replace `kotlinOptions` with the modern `compilerOptions` DSL. Keep everything else (NDK, CMake, minSdk) unchanged.
    
    groovy
    apply plugin: "com.android.library"
    
    // AGP 9.0+ provides built-in Kotlin and no longer supports applying the
    // Kotlin Gradle Plugin. Only apply KGP when the consumer's AGP is older.
    def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int
    if (agpMajor < 9) {
        apply plugin: 'kotlin-android'
    }
    
    android {
        // ... existing content unchanged (namespace, compileSdk, ndkVersion,
        //     externalNativeBuild, sourceSets, compileOptions, defaultConfig) ...
    
        // REMOVE the old kotlinOptions block (lines 60-62)
    }
    
    kotlin {
        compilerOptions {
            jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
        }
    }
    
    dependencies {
        // ... unchanged ...
    }
    
    
    Also update the `buildscript` block:
    - Bump KGP to `2.0.0` or later (`ext.kotlin_version = "2.1.0"`) — the `compilerOptions` DSL requires KGP 2.0+, and this version is what the AGP `< 9` fallback path needs.
    - Keep (or bump to `9.x`) the AGP classpath so the plugin still builds standalone and to exercise the AGP 9 path in tests.
    - Add a short comment above the new `kotlin {}` block noting it mirrors `kotlinOptions` at `JVM_1_8` to match the `compileOptions` (JVM 17 is only needed if you also raise `compileOptions`).
    
    ## 3. Bump minimum Flutter/Dart versions in `pubspec.yaml`
    
    Per the guide, the `kotlin { compilerOptions {} }` DSL requires KGP 2.0.0, which only arrives with Flutter 3.44. Update `zstandard_android/pubspec.yaml:8-10`:
    
    yaml
    environment:
      sdk: ^3.12.0
      flutter: '>=3.44.0'
    
    
    - Also bump the dependent package versions so the constraint resolves correctly. The repo centralizes versions (see `docs/development/release-process.md`), so plan a **MINOR** release (e.g. `1.6.0`) across `zstandard_android`, `zstandard` (which depends on `zstandard_android`), and the other federated packages so pub can resolve the new minimums.
    
    ## 4. Migrate the example apps (app-developers migration)
    
    Both example apps still apply KGP and must be migrated, since the plugin's own build is exercised through them:
    
    **`zstandard_android/example/android/settings.gradle:19-23`** — bump AGP to `9.x` and drop the KGP plugin declaration:
    gradle
    plugins {
        id "dev.flutter.flutter-plugin-loader" version "1.0.0"
        id "com.android.application" version "9.0.0" apply false
    }
    
    
    **`zstandard_android/example/android/app/build.gradle:1-6`** — remove `id "kotlin-android"` and the `kotlinOptions` block (`:18-20`); add the `kotlin.compilerOptions {}` block if you need to pin the target:
    gradle
    plugins {
        id "com.android.application"
        // The Flutter Gradle Plugin must be applied after the Android Gradle plugin.
        id "dev.flutter.flutter-gradle-plugin"
    }
    
    kotlin {
        compilerOptions {
            jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
        }
    }
    
    
    **`zstandard_android/example/android/gradle.properties`** — add to enable/validate built-in Kotlin (requires Flutter 3.47+):
    properties
    android.builtInKotlin=true
    
    
    Apply the same four changes to `zstandard/example/android/` (`settings.gradle`, `app/build.gradle`, `build.gradle`, `gradle.properties`) since the main package's example also applies KGP.
    
    ## 5. Update the CHANGELOG
    
    Add an entry at the top of `zstandard_android/CHANGELOG.md` (and the root `CHANGELOG.md`, which is copied per package on release):
    
    markdown
    ## 1.6.0 - Built-in Kotlin
    
    - Migrated to built-in Kotlin for AGP 9.0+ compatibility.
    - Applies the Kotlin Gradle Plugin only when the consumer's AGP is older than 9.
    - Updates the minimum supported SDK to Flutter 3.44 / Dart 3.12.
    
    
    ## 6. Validate locally
    
    - `flutter analyze` in `zstandard_android` and `zstandard`.
    - `flutter test` in `zstandard_android` (unit tests).
    - From `zstandard_android/example`, run the integration tests on an emulator:
      bash
      flutter test integration_test/ -d emulator-5554
      
      or a plain build sanity check:
      bash
      flutter build apk --debug
      
    - **Test both code paths**:
      1. **AGP 9 + built-in Kotlin**: run the example with AGP `9.x`, `android.builtInKotlin=true`, on Flutter `3.47+`.
      2. **Backward compat (AGP 8 + KGP)**: run the example with AGP `8.x` and KGP `2.0+` to confirm the conditional branch still applies KGP and builds.
    
    ## 7. Update CI
    
    `pr_check_android.yml` currently pins `FLUTTER_VERSION: '3.41.4'` (`:14`), which predates the changes. Update it to `3.47`+ (or add a version matrix covering both the old and new Flutter/AGP combos) so the emulator integration tests in that workflow exercise the migrated build. Keep the pub-cache variant (`check_android_test_from_pub_cache`) as-is.
    
    ## 8. Documentation
    
    - Add a short "Requirements" note to `docs/platforms/android.md` mentioning that `zstandard_android` 1.6.0+ requires Flutter 3.44+ and works with both AGP 8 (via KGP) and AGP 9+ (built-in Kotlin).
    - If the README's compatibility tables ever list Kotlin/Gradle specifics, note the AGP 9.0 requirement there too.
    
    ---
    
    **Notes / caveats**
    - The plugin's own `build.gradle` `buildscript` block only affects standalone/Android-Studio builds; when consumed by an app, the app's AGP/KGP classpath governs the `agpMajor` check, which is exactly what the conditional logic keys on.
    - Keep `jvmTarget` aligned with `compileOptions` (`1.8`); only bump to `JVM_17` if you also raise `compileOptions`, which is a larger breaking change and not required for this issue.
    - Ship the version bump as one release across all federated packages so pub.dev resolves the new `zstandard_android` minimum consistently with `zstandard`.
    [INFO] Main run finished. Results: 7, total steps: 6.
    [INFO] Publishing result: 7 result(s), 6 step(s), 0 error(s).
    [INFO] 📄 Executing PublishResultUseCase.
    

    🚀 Happy coding!

    Made with ❤️ by vypdev/copilot

  4. efraespada commented on Aug 20, 2026

    @efraespada
    Member

    This will be fixed on a couple of days. Thanks for reporting @maximilianoe

  5. maximilianoe commented on Sep 1, 2026

    @maximilianoe
    Author

    @efraespada In case you can't handle this at the moment, please add me as collaborator and I will open the PR.

  6. efraespada commented on Sep 2, 2026

    @efraespada
    Member

    Temporary workaround until the next pub.dev release:

    The Built-in Kotlin migration for this issue is now available on the master branch.

    To consume the fixed Android package from this repository:

    dependency_overrides:
      zstandard_android:
        git:
          url: https://github.com/vypdev/zstandard.git
          ref: master
          path: zstandard_android

    If the application depends on the federated zstandard package, overriding only the root package does not replace its transitive platform package, so zstandard_android must be overridden explicitly.

    Switch back to the published package when the next release is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

  • Status
    Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions