Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

The Kotlin Gradle Plugin (KGP) version error in a Flutter project using flutter_html_to_pdf is usually a mismatch in Android build configuration—not proof that the package itself must be replaced. Find where your project declares Kotlin, check the complete Gradle error and the Flutter, Android Gradle Plugin (AGP), and Gradle wrapper versions, then update the declaration your project actually uses. There is no single Kotlin version that is correct for every Flutter toolchain.

What the error means

Flutter’s Android build invokes Gradle, which in turn uses the Kotlin Gradle Plugin to compile Kotlin code. An error such as “Your project requires a newer version of the Kotlin Gradle plugin” means that a Kotlin plugin version found by the build is below the requirement being enforced by the Flutter or Android build configuration in use.

The error may mention a particular Gradle file, but its location depends on the project template and Flutter version. The version can be declared in the app’s Android build files, while an Android library plugin can also have its own Gradle configuration. Treat the full error—not just the package name or one line copied from it—as the starting point.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Find the Kotlin version declaration used by your project

Flutter projects created with newer Gradle conventions commonly declare plugin versions in android/settings.gradle or android/settings.gradle.kts. Older projects may declare Kotlin in a buildscript block in android/build.gradle, often as ext.kotlin_version. Flutter’s default Gradle scripts changed with Flutter 3.16, but projects are not all regenerated when Flutter is upgraded.

  1. Open the complete build output and note the file and plugin named in the first relevant Kotlin or Gradle error.
  2. Check android/settings.gradle and android/settings.gradle.kts, if present, for a plugins block containing org.jetbrains.kotlin.android or another Kotlin plugin ID and a version.
  3. If the project uses the older layout, inspect android/build.gradle for a buildscript block and ext.kotlin_version. Look at the app module’s Gradle file as well to see how the plugin is applied.
  4. Record the Android Gradle Plugin version, the Gradle wrapper version in android/gradle/wrapper/gradle-wrapper.properties, and the Flutter version used for the build. These versions need to work together with KGP.
  5. If the error points into a dependency rather than your app’s Android files, check which dependency and version are actually resolved. Do not assume the app’s Kotlin declaration is the only one involved.

Change the existing version declaration in the configuration your project uses. Adding a second Kotlin plugin declaration to a different file can leave the original version active or create a conflicting build setup.

Choose between a targeted version update and a Gradle migration

Route Best fit What changes Main caution
Update the existing KGP version The project has a working Gradle layout and the error identifies an outdated or unsupported Kotlin plugin version. Change the current Kotlin plugin version declaration, then build again. Check compatibility with the project’s AGP, Gradle wrapper, and Flutter release; do not pick a version based only on the word “latest.”
Migrate the Gradle setup The project still uses a legacy imperative Flutter Gradle setup, or an AGP 9 migration requirement applies. Move toward the declarative Flutter Gradle Plugin DSL or follow the applicable built-in Kotlin migration instructions. This is a broader build-system change. Generated files differ by Flutter version, and plugins may need migration support.

Route 1: update the version your project already declares

Use the compatibility guidance for the exact Flutter release and the AGP and Gradle versions in the project. Flutter’s historical Kotlin breaking-change guidance says Android builds require Kotlin 1.5.31 or greater for the situation it documents. That page also warns its workaround guidance may not remain current. Treat 1.5.31 as historical context, not as a universal recommendation for a current project.

In a Plugin DSL layout, edit the Kotlin plugin version in the existing plugins block in android/settings.gradle or its Kotlin DSL equivalent. In a legacy layout, edit the existing ext.kotlin_version declaration in android/build.gradle. Preserve the project’s existing plugin IDs and structure; do not paste an unrelated template over the file.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Route 2: migrate legacy Gradle scripts when appropriate

Flutter’s declarative migration guide demonstrates moving AGP and Kotlin version declarations into a plugins {} block in settings.gradle, applying the Android, Kotlin, and Flutter plugins in the app module, and removing the old buildscript block. It also says to remove an explicit kotlin-stdlib-jdk7 dependency if the project has one. The precise edits depend on the generated files and Flutter version, so follow the official migration guide for your project rather than copying a generic example.

A migration may be more appropriate than a narrow KGP bump if the error is part of a wider move away from legacy Gradle configuration. Avoid doing both changes speculatively: make a deliberate configuration change, rebuild, and use the next first error to decide what to address.

Special case: AGP 9 and built-in Kotlin

AGP 9 changes the decision. Flutter’s guidance says AGP 9 uses built-in Kotlin by default, and projects or plugins that apply the legacy KGP need to follow the relevant migration instructions rather than blindly applying an older version bump. Flutter’s plugin-author documentation describes temporary AGP 9 support with built-in Kotlin disabled in Flutter 3.44, and says enabling built-in Kotlin requires Flutter 3.47 or later. These are release-specific thresholds, so check the current official Flutter guidance before acting on them.

Check whether flutter_html_to_pdf is the source

flutter_html_to_pdf is a Flutter plugin for generating PDF documents from HTML. The pub.dev versions listing available for this article showed 0.7.0 as its latest stable listed version, uploaded about four years before that listing was crawled. An older package release is a reason to inspect its Android Gradle configuration, but it does not establish that the package caused a particular project’s Kotlin error.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A community question about this package and a Kotlin-version error points to a package Android Gradle file declaring KGP 1.3.50. That is below Flutter’s historical 1.5.31 minimum guidance. This is a plausible package-side cause only if the resolved version in your own project contains that declaration; the report does not establish that every published release does. Verify the dependency version in your lockfile and resolved package cache, and check whether another Android plugin contributes an older Kotlin declaration.

Do not replace the package as the first repair. The existence of a separately named package such as flutter_html_to_pdf_v2 does not establish that it is an official migration path or that it will fix this build. First identify which project or dependency supplies the version named in the actual error.

Rebuild and verify the change

  1. Save the single configuration change you chose: the existing KGP declaration, or the migration edits appropriate to the project.
  2. Run your normal Flutter Android build command, such as flutter build apk, from the project root. For a targeted diagnostic, run cd android && ./gradlew assembleDebug on macOS or Linux; on Windows use gradlew.bat assembleDebug from the android directory.
  3. Read the first new Gradle error in full. A changed error can indicate the Kotlin version check is passed and the next incompatibility is elsewhere; it is not a reason to keep changing versions at random.
  4. Once the build succeeds, run the app’s relevant tests or exercise the HTML-to-PDF path to check that resolving the build issue did not introduce a separate runtime or document-generation problem.

Cleaning build outputs can be useful after dependency or Gradle configuration changes, but deleting caches does not correct an incompatible Kotlin declaration. Use a clean only when the error suggests stale build state, not as the primary fix for a version mismatch.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common failure paths

The error still names the old Kotlin version

You may have edited a declaration the project does not use, or a dependency may be supplying the older version. Search the Android Gradle files for Kotlin plugin IDs, kotlin_version, and the version shown in the error. Then inspect the resolved dependency named by Gradle and make the change at the configuration source that is actually active.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The new Kotlin version causes a different Gradle error

KGP, AGP, the Gradle wrapper, and Flutter have compatibility constraints. Recheck all four against current guidance rather than assuming a Kotlin-only change is sufficient. Restore the last known configuration if necessary, then choose a compatible combination instead of layering another version declaration on top.

The project has both settings.gradle and an old buildscript block

That can happen in projects partway through a migration. Establish which setup the project applies and follow the migration path for that Flutter template. Keeping two competing declarations can make it unclear which plugin version Gradle resolves.

The build uses AGP 9 or a plugin applies legacy KGP

Do not treat this as the ordinary “raise Kotlin to a newer number” case. Follow Flutter’s AGP 9 and built-in Kotlin instructions for the Flutter release in use, and check whether the Android plugin itself needs an update or migration.

A cache clean did not help

Return to the complete first error and verify the declared and resolved versions. A clean can remove stale outputs, but if Gradle is still loading the same incompatible plugin declaration, the mismatch remains.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Or skip the browser setup

This Kotlin Gradle error is fixed in Android build configuration; ScreenshotNeo is not a substitute for that repair. For a separate need—capturing a website as an image or PDF—ScreenshotNeo offers a screenshot API and MCP server. A single GET request can return a screenshot or PDF; see the API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Sign up free for 1,000 screenshots a month with no card.

Frequently Asked Questions

Does changing the Kotlin version in pubspec.yaml fix this error?

No. The Kotlin Gradle Plugin version is part of Android’s Gradle build configuration, not a Flutter package version entry in pubspec.yaml.

Should I downgrade flutter_html_to_pdf to fix the Kotlin error?

Not without evidence that the resolved package version is contributing the conflicting declaration. Identify the version Gradle actually resolves and follow the error to its source first.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.