How to Fix the Kotlin Gradle Plugin Version Error in flutter_html_to_pdf
Fix Kotlin Gradle plugin errors in flutter_html_to_pdf by finding the version declaration your Flutter project actually uses and checking toolchain compatibility.

Direct answer: this is usually an Android build configuration or compatibility issue. Find the Kotlin Gradle Plugin (KGP) version declaration used by your Flutter project, update that declaration to a version compatible with your Flutter SDK, Android Gradle Plugin (AGP), and Gradle wrapper, then rebuild. Newer Flutter templates commonly declare plugin versions in android/settings.gradle; older templates often use ext.kotlin_version in android/build.gradle. Do not add a second Kotlin declaration or choose a version just because it is the latest.
The package flutter_html_to_pdf converts HTML to PDF. Its age or a related report mentioning Kotlin 1.3.50 can be a clue to inspect, but neither proves that your resolved package is the cause. Check the actual error, project files, and resolved plugin configuration before changing anything.
1. Identify which project is declaring Kotlin
Read the full Gradle error first. Note the file path it names and whether it points into your app’s android/ directory or into a dependency’s Android Gradle files. These are different configurations: changing the app’s KGP declaration may not override a plugin that independently applies or declares an older Kotlin plugin.
Record the versions and locations before editing:
- Flutter SDK version (
flutter --version) - AGP version, usually in
android/settings.gradleor an older buildscript - Gradle wrapper version in
android/gradle/wrapper/gradle-wrapper.properties - KGP version and its declaration location
- The resolved
flutter_html_to_pdfversion frompubspec.lock
Flutter’s Kotlin breaking-change guidance documented a minimum of Kotlin 1.5.31 for the builds covered by that guidance, and shows the error “Your project requires a newer version of the Kotlin Gradle plugin.” That page warns its workaround guidance may become outdated. Treat 1.5.31 as historical context, not as a universal current recommendation. Check Flutter’s Kotlin version guidance alongside the current compatibility requirements for your toolchain.
2. Locate and update the existing declaration
Newer Plugin DSL project
Since Flutter 3.16, generated projects commonly declare plugin versions in android/settings.gradle. The relevant block may look like this:

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "AGP_VERSION" apply false
id "org.jetbrains.kotlin.android" version "KGP_VERSION" apply false
}
Replace KGP_VERSION with a version selected for your Flutter, AGP, and Gradle combination. The placeholder above is explanatory, not a literal version. Preserve the other plugin declarations and their ordering as generated for your project. Avoid adding another org.jetbrains.kotlin.android entry elsewhere to silence the message.
Older buildscript project
Older Flutter templates may define the version in android/build.gradle:
buildscript {
ext.kotlin_version = 'KGP_VERSION'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:AGP_VERSION'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Update the existing ext.kotlin_version value rather than creating a second variable or adding a separate plugin version. Keep the AGP and Gradle wrapper compatible with the chosen KGP. The sample uses placeholders because there is no safe single version that fits every Flutter and Android toolchain.
Check the resolved package before blaming it
A community report associated with this package describes an Android Gradle file using KGP 1.3.50. That is below the minimum in Flutter’s cited historical guidance, so it is a plausible package-side lead if your resolved dependency actually contains that declaration. It is not evidence that every release embeds it or that it caused your build failure.
- Find the resolved package version in
pubspec.lock. - Inspect the package’s Android Gradle files in the resolved pub cache or source archive.
- Compare the declaration and the complete error path with your app’s KGP setup.
- Check whether another Android plugin also contributes an older KGP declaration.
The pub.dev listing returned for this research showed 0.7.0 as the latest stable package release and indicated it was uploaded about four years before the page was crawled. Release age is a reason to inspect compatibility; it does not prove the package is incompatible with your project. See the package version listing and verify what your lockfile actually resolves.
3. Choose between a targeted update and migration
| Route | Use when | Scope |
|---|---|---|
| Update the existing KGP declaration | Your project already uses a supported layout and the error identifies a version mismatch. | Usually the smallest change; still verify AGP and wrapper compatibility. |
| Migrate legacy Gradle scripts | Your project uses an older imperative Flutter Gradle setup and you intend to adopt the declarative Plugin DSL. | Changes plugin declaration and application locations; follow the guide for your Flutter version. |
| Follow built-in Kotlin migration | Your project uses AGP 9 or later and legacy KGP application is involved. | Requires Flutter-specific migration guidance; a simple version bump may be the wrong change. |
Flutter’s Gradle Plugin DSL migration guide shows versions in settings.gradle, plugin application in the app module, and removal of the old buildscript block. It also says generated files vary by Flutter version. Follow the guide against your actual project rather than pasting a template over it. If the app module has an explicit kotlin-stdlib-jdk7 dependency, the guide says to remove it during the documented migration.

AGP 9 changes the picture because built-in Kotlin is enabled by default. Flutter’s current built-in Kotlin migration guidance and plugin-author migration notes describe release-specific thresholds and temporary support details. Those thresholds can change; check the live guidance before editing an AGP 9 project. Do not apply an older KGP bump mechanically.
4. Rebuild and read the next error
After changing the one declaration you identified, rebuild using the command appropriate to your workflow:
flutter clean
flutter pub get
flutter build apk -v
For an Android App Bundle, use flutter build appbundle -v. Inspect the first remaining Gradle error and its file path. A cache clean can help after dependency or build configuration changes, but clearing caches does not make incompatible versions compatible. If the next error names a different plugin or a Gradle API, diagnose that specific issue rather than repeatedly changing Kotlin versions.
Common errors and fixes
| Symptom | Likely cause | What to do |
|---|---|---|
| “Your project requires a newer version of the Kotlin Gradle plugin” | The build’s effective KGP is below the requirement reported by the installed Flutter/toolchain. | Find the active declaration, check all toolchain versions, and update that declaration compatibly. |
| Version changed but the same message remains | You edited an unused file, have duplicate declarations, or a dependency applies its own KGP. | Follow the error’s file path; search both app Gradle files and the resolved plugin’s Android files. |
| “Plugin already on the classpath” or plugin resolution conflict | Legacy buildscript and Plugin DSL declarations are both supplying the Kotlin plugin. | Keep the project’s established setup or complete the documented migration; remove duplicate configuration. |
| Gradle cannot resolve a plugin or artifact | Repository configuration, network access, or a mismatched plugin declaration may be involved. | Check the complete resolution message and repositories; do not assume this is the Kotlin minimum-version error. |
| Build fails after moving to AGP 9 | Legacy KGP application may conflict with AGP’s built-in Kotlin behavior or Flutter support state. | Use Flutter’s current AGP 9 and built-in Kotlin migration instructions for your Flutter release. |
| Clean build still fails with a compatibility error | The version combination remains incompatible; cache state was not the underlying issue. | Recheck KGP, AGP, Gradle wrapper, Flutter, and plugin requirements as a set. |
Reliability, build time, and maintenance
Make the smallest version-aware change first when the project is otherwise on a supported Gradle layout. Broad migration touches multiple build files and can surface unrelated plugin compatibility issues, so schedule it as a separate change when practical. Conversely, repeatedly pinning an old KGP to satisfy one dependency can leave the app below Flutter’s requirement or out of step with AGP.
Gradle dependency resolution and a clean rebuild take time, but cache deletion is not a version strategy. Keep the lockfile and Gradle configuration changes reviewable, and record the Flutter, AGP, wrapper, and KGP versions together so later upgrades have context. The researched sources do not establish a package replacement as necessary; switching to a similarly named package is not a default fix.
Or skip the browser setup
If your task is to capture a rendered page or PDF while documenting or debugging this integration, ScreenshotNeo is a website screenshot API and MCP server. Its one-call request can return an image or PDF; the Flutter Gradle repair above still needs to happen in your project.
curl -G "https://api.screenshotneo.com/v1/shot" \
-d access_key=YOUR_API_KEY \
--data-urlencode url=https://stripe.com \
-o shot.webp
See the ScreenshotNeo docs for request options. Cookie banners are accepted and removed before the shot, along with supported newsletter popups and chat widgets. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, with response headers indicating page verdict and billing. An MCP server gives AI agents tools to take screenshots, inspect page info, and capture PDFs. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.
Sign up for ScreenshotNeo’s free plan and get 1,000 screenshots a month with no card.
FAQ
Is Kotlin 1.5.31 always the right fix?
No. That is a minimum from Flutter’s historical guidance, which warns it may become outdated. Select a compatible version for the current Flutter, AGP, and Gradle combination.
Does flutter_html_to_pdf definitely ship Kotlin 1.3.50?
The research includes a related community report citing that version, not verification of every published archive. Inspect your resolved package files before drawing that conclusion.
Should I replace the package with flutter_html_to_pdf_v2?
The evidence does not establish replacement as necessary or identify that package as an official migration path. Diagnose the Gradle error and dependency configuration first.
Where can I confirm which Flutter template I have?
Inspect android/settings.gradle and android/build.gradle for the active plugin declarations, then compare their layout with Flutter’s migration documentation for your installed SDK.


