# Flutter “Applying Gradle Plugin Imperatively” Error: The Fix

> Applying Flutter's main Gradle plugin imperatively fails since Flutter 3.29. How to move to the plugins {} block, from Flutter docs checked Oct 21, 2026.

Canonical: https://app369.com/blog/flutter-gradle-plugin-applied-imperatively-fix-2026/
Last updated: 2026-10-21

[![Simon Dziak](https://app369.com/.netlify/images?w=48&amp;h=48&amp;fm=webp&amp;q=100&amp;url=%2Fimages%2Fszymon.jpg) **Simon Dziak** Founder & developer, App369](https://app369.com/about/szymon-dziak/) [LinkedIn](https://www.linkedin.com/in/szymondziak/)

Published October 18, 2026 · Updated October 21, 2026•Facts last verified October 21, 2026•7 min

App369https://app369.com/blog/flutter-gradle-plugin-applied-imperatively-fix-2026/

[← Back to Blog](https://app369.com/blog/)

## Key takeaways

- →Flutter 3.16 added support for applying its Gradle plugins with the declarative plugins {} block, and Flutter 3.19 made it the recommended way. Projects created before 3.16 have to be migrated by hand.
- →Flutter removed support for the old apply from: flutter.gradle method in pull request #160947, merged January 7, 2025. Flutter 3.29.0, released February 12, 2025, is the first stable release that includes it.
- →The build now stops with "You are applying Flutter's main Gradle plugin imperatively using the apply script method, which is not possible anymore." A similar message names the app_plugin_loader plugin when settings.gradle uses the old method.
- →The fix touches three files: android/settings.gradle gets a pluginManagement and plugins block, android/build.gradle loses its buildscript block, and android/app/build.gradle swaps its apply lines for a plugins block.
- →Firebase projects also move the Google Services and Crashlytics Gradle plugins out of buildscript and into the same plugins blocks.

Pricing an app? Try the free [app cost calculator](https://app369.com/tools/app-cost-calculator/) or get a range for your project in the [instant quote](https://app369.com/instant-quote/).

**If an Android build fails with “You are applying Flutter’s main Gradle plugin imperatively using the apply script method, which is not possible anymore”, your Gradle files still load Flutter the pre-3.16 way.** Flutter 3.29 removed support for that method, so the old `flutter.gradle` file now does nothing but throw this error. The fix is to move three Gradle files to the declarative `plugins {}` block. It changes how the build is wired, not your app’s code.

If you landed here from the link in the error message, flutter.dev/to/flutter-gradle-plugin-apply, it still opens Flutter’s migration page. This guide follows that page and adds what the page doesn’t say: when the old method stopped working, and the Firebase case most older apps have. The facts come from Flutter’s docs, its source code and its release archive, as listed in the sources. I checked each one on October 21, 2026.

**Disclosure:** App369 is my studio. I build and fix Flutter apps, and the last section mentions what I sell. Google doesn’t pay me for anything on this page.

## What changed, and when

| Date | What happened | Source |
| --- | --- | --- |
| November 15, 2023 | Flutter 3.16 adds support for the declarative `plugins {}` block. New `flutter create` projects use it | [Flutter docs](https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply), [release archive](https://storage.googleapis.com/flutter_infra_release/releases/releases_macos.json) |
| February 15, 2024 | Flutter 3.19: the declarative block is the recommended way | [Flutter docs](https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply), [release archive](https://storage.googleapis.com/flutter_infra_release/releases/releases_macos.json) |
| January 7, 2025 | Pull request #160947 removes support for the imperative apply | [Flutter PR #160947](https://github.com/flutter/flutter/pull/160947) |
| **February 12, 2025** | **Flutter 3.29.0, the first stable release that includes that change** | [Release archive](https://storage.googleapis.com/flutter_infra_release/releases/releases_macos.json), [Flutter PR #160947](https://github.com/flutter/flutter/pull/160947) |

Flutter’s docs page lists only when the new method was supported and recommended. The removal date comes from the pull request. I checked that its commit is in the 3.29.0 tag and not in 3.27. In 3.27 the old file only logged a deprecation error and the build still ran.

### The two versions of the error

Both come from files in Flutter’s own Gradle folder that now exist only to throw an error:

- `flutter.gradle`: “You are applying Flutter’s main Gradle plugin imperatively using the apply script method, which is not possible anymore.” This means `android/app/build.gradle` still has `apply from: ".../flutter.gradle"`.
- `app_plugin_loader.gradle`: “You are applying Flutter’s app_plugin_loader Gradle plugin imperatively using the apply script method, which is not possible anymore.” This means `android/settings.gradle` still loads the plugin loader the old way.

Both point to the same migration page, and the fix below covers both. The snippets use Groovy, as Flutter’s page does. If your project uses Kotlin DSL files (`settings.gradle.kts`), the same plugin IDs go in the same places, written as `id("dev.flutter.flutter-plugin-loader") version "1.0.0"` with parentheses and double quotes.

## The fix, file by file

These steps follow Flutter’s [migration page](https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply). My advice: commit or back up the `android` folder before you start, so you can compare.

### 1. Note your AGP and Kotlin versions

Open `android/build.gradle`. In the `buildscript` block, the Android Gradle Plugin version is the number at the end of `classpath 'com.android.tools.build:gradle:...'`, and the Kotlin version is in `ext.kotlin_version = '...'`. You need both in the next step. If the build only started failing after an upgrade to AGP 9, [the AGP 9 build fix for Flutter](https://app369.com/blog/flutter-android-gradle-plugin-9-build-failed-fix-2026/) covers that case.

### 2. Replace android/settings.gradle

Flutter’s page gives this as the new contents. Replace `{agpVersion}` and `{kotlinVersion}` with the versions from step 1:

```
pluginManagement {
    def flutterSdkPath = {
        def properties = new Properties()
        file("local.properties").withInputStream { properties.load(it) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        return flutterSdkPath
    }()

    includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "{agpVersion}" apply false
    id "org.jetbrains.kotlin.android" version "{kotlinVersion}" apply false
}

include ":app"
```

If you had your own code in this file, keep it after the `pluginManagement {}` and `plugins {}` blocks. Gradle doesn’t allow other code before them. The plugin loader must not be set to `apply false`.

### 3. Remove buildscript from android/build.gradle

Delete the whole `buildscript { ... }` block. The `allprojects`, `subprojects` and `clean` parts stay.

### 4. Update android/app/build.gradle

Remove the `def flutterRoot = localProperties.getProperty('flutter.sdk')` line and the `if (flutterRoot == null) { throw ... }` block that follows it. Keep the code that loads `local.properties`, which the version settings still use. Then remove the old apply lines. In Flutter 3.10’s `flutter create` template they look like this:

```
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
```

Then add this at the very top of the file:

```
plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}
```

Flutter’s page points out that `dev.flutter.flutter-gradle-plugin` here is a different ID from `dev.flutter.flutter-plugin-loader` in `settings.gradle`. If the `dependencies` block has `org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version`, remove that line.

### 5. Build and run

Flutter’s page says to run `flutter run` and check that the app builds and launches on an Android device or emulator.

## If the app uses Firebase

If your app uses Firebase, its Google Services plugin, and Crashlytics if you use it, are probably applied the old way too. Flutter’s page covers this case:

1. In `android/build.gradle`, remove the `classpath` lines for `com.google.gms:google-services` and `com.google.firebase:firebase-crashlytics-gradle`. Note their versions first.
2. In `android/app/build.gradle`, remove `apply plugin: 'com.google.gms.google-services'` and `apply plugin: 'com.google.firebase.crashlytics'`.
3. Add both to the `plugins` block in `android/settings.gradle`, with the versions you noted and `apply false`:```
id "com.google.gms.google-services" version "4.4.0" apply false
id "com.google.firebase.crashlytics" version "2.9.9" apply false
```
4. Add `id "com.google.gms.google-services"` and `id "com.google.firebase.crashlytics"` to the `plugins` block in `android/app/build.gradle`, without versions.

The versions above are the ones in Flutter’s example. Use the versions your project had, or newer ones.

## If the build still fails after this

In my view, a project old enough to hit this error usually has more than one problem waiting: old plugins, an old AGP or Gradle version, or the v1 embedding. If the next error says “Build failed due to use of deleted Android v1 embedding”, see [the v1 embedding fix](https://app369.com/blog/flutter-deleted-android-v1-embedding-build-failed-2026/), also removed in Flutter 3.29. If Gradle can’t find `jcenter()`, see [the JCenter guide](https://app369.com/blog/jcenter-bintray-shut-down-fix-android-flutter-builds-2026/).

If it says “Unsupported class file major version”, your Java is newer than your Gradle: see [the Java and Gradle version fix](https://app369.com/fix/flutter-unsupported-class-file-major-version/).

## Need a hand?

If an older Flutter app won’t build after an upgrade, the [App Fix Ticket](https://app369.com/fixed-price/flutter-firebase-bug-fix/) covers it in two fixed-price steps. A $450 Diagnosis gives you the root cause with evidence and a fixed repair quote within 3 business days, credited toward the fix. If you go ahead, the $1,200 Fix takes 5 business days and comes as a pull request. Or [send me a short description](https://app369.com/contact/).

## **Want this done at a fixed price?**

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

- [**App Fix Ticket**from $450One reproducible bug in an existing mobile or web app, diagnosed and fixed.](https://app369.com/fixed-price/flutter-firebase-bug-fix/)

## **Frequently asked questions**

<dl>

<dt>**What does "applying Flutter's main Gradle plugin imperatively" mean?**</dt>
<dd>Your android/app/build.gradle still loads Flutter's Gradle plugin with apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle". Flutter removed support for that method, and in Flutter 3.29 and later that file only throws this error. The fix is to apply the plugin with the declarative plugins {} block.</dd>

<dt>**Which Flutter version made the imperative apply an error?**</dt>
<dd>Flutter 3.29. The change that removed support, Flutter pull request #160947, was merged on January 7, 2025 and is included in the 3.29.0 tag but not in 3.27. Flutter's release archive dates 3.29.0 February 12, 2025.</dd>

<dt>**How do I fix the error?**</dt>
<dd>Follow Flutter's "Deprecated imperative apply of Flutter's Gradle plugins" page: put a pluginManagement block and a plugins block with dev.flutter.flutter-plugin-loader in android/settings.gradle, remove the buildscript block from android/build.gradle, and replace the apply lines in android/app/build.gradle with a plugins block that includes dev.flutter.flutter-gradle-plugin.</dd>

<dt>**What is the difference between flutter-plugin-loader and flutter-gradle-plugin?**</dt>
<dd>Flutter's docs say dev.flutter.flutter-plugin-loader is the settings plugin and goes in settings.gradle, while dev.flutter.flutter-gradle-plugin is the project plugin and goes in app/build.gradle. They are different IDs, and the loader must not be set to apply false.</dd>

<dt>**What about google-services and Crashlytics?**</dt>
<dd>Flutter's docs show removing their classpath lines from android/build.gradle and their apply plugin lines from app/build.gradle, then adding com.google.gms.google-services and com.google.firebase.crashlytics with versions and apply false to the settings.gradle plugins block, and without versions to the app/build.gradle plugins block.</dd>

</dl>

## **Sources**

1. [Flutter docs, Deprecated imperative apply of Flutter's Gradle plugins (last updated July 31, 2026)](https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply)
2. [Flutter on GitHub, pull request #160947 "Remove support for imperative apply of Flutter Gradle Plugin"](https://github.com/flutter/flutter/pull/160947)
3. [Flutter on GitHub, flutter_tools gradle/flutter.gradle](https://github.com/flutter/flutter/blob/master/packages/flutter_tools/gradle/flutter.gradle)
4. [Flutter on GitHub, flutter_tools gradle/app_plugin_loader.gradle](https://github.com/flutter/flutter/blob/master/packages/flutter_tools/gradle/app_plugin_loader.gradle)
5. [Flutter on GitHub, Flutter 3.10.0 app/build.gradle template](https://github.com/flutter/flutter/blob/3.10.0/packages/flutter_tools/templates/app_shared/android-kotlin.tmpl/app/build.gradle.tmpl)
6. [Flutter release archive (macOS)](https://storage.googleapis.com/flutter_infra_release/releases/releases_macos.json)
7. [Flutter on GitHub, Flutter 3.27.0 flutter_tools gradle/flutter.gradle (deprecation message only)](https://github.com/flutter/flutter/blob/3.27.0/packages/flutter_tools/gradle/flutter.gradle)
8. [Flutter on GitHub, Flutter 3.29.0 settings.gradle.kts template (Kotlin DSL)](https://github.com/flutter/flutter/blob/3.29.0/packages/flutter_tools/templates/app/android.tmpl/settings.gradle.kts.tmpl)

Tags

#applying flutter main gradle plugin imperatively #apply script method not possible anymore #flutter gradle plugin declarative #dev.flutter.flutter-gradle-plugin #dev.flutter.flutter-plugin-loader #app_plugin_loader gradle imperatively #flutter 3.29 android build error #flutter settings.gradle pluginManagement #google-services plugins block flutter

Generated from app369.com . © 2026 App369. All rights reserved.

**Share:**

[Share on Twitter](https://twitter.com/intent/tweet?text=Flutter%20%22Applying%20Gradle%20Plugin%20Imperatively%22%20Error%3A%20The%20Fix&amp;url=https%3A%2F%2Fapp369.com%2Fblog%2Fflutter-gradle-plugin-applied-imperatively-fix-2026%2F) [Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fapp369.com%2Fblog%2Fflutter-gradle-plugin-applied-imperatively-fix-2026%2F) [Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fapp369.com%2Fblog%2Fflutter-gradle-plugin-applied-imperatively-fix-2026%2F)

## **Related Resources **

[Flutter "Deleted Android v1 Embedding" Build Error: The Fix](https://app369.com/blog/flutter-deleted-android-v1-embedding-build-failed-2026/) [Flutter Android Build Fails After AGP 9: The Fix](https://app369.com/blog/flutter-android-gradle-plugin-9-build-failed-fix-2026/) [Google Play 16 KB Page Size: Fixing Flutter and Android Apps](https://app369.com/blog/google-play-16kb-page-size-flutter-android-2026/) [Google Play Requires Target API 36: The Android 16 Update](https://app369.com/blog/google-play-target-api-36-android-16-requirement-2026/) [JCenter Shutdown: Fixing Old Android and Flutter Builds](https://app369.com/blog/jcenter-bintray-shut-down-fix-android-flutter-builds-2026/) [Google Sign-In for Android Is Deprecated: Moving to Credential Manager](https://app369.com/blog/google-sign-in-android-deprecated-credential-manager-2026/)

## **Related guides **

[<h3>**Flutter "Deleted Android v1 Embedding" Build Error: The Fix**</h3>Build failed due to use of deleted Android v1 embedding? Flutter 3.29 removed v1. The AndroidManifest and MainActivity fixes, from docs checked Oct 21, 2026.**Read more **](https://app369.com/blog/flutter-deleted-android-v1-embedding-build-failed-2026/) [<h3>**JCenter Shutdown: Fixing Old Android and Flutter Builds**</h3>JCenter shutdown: Bintray closed in 2021 and Gradle 9 removed jcenter(). How to fix an old Android or Flutter build that still uses it, checked Oct 18, 2026.** Read more **](https://app369.com/blog/jcenter-bintray-shut-down-fix-android-flutter-builds-2026/) [<h3>**Flutter iOS Build Failed After an Upgrade? Fix CocoaPods and Xcode Errors (2026)**</h3>Flutter iOS build failed after upgrading Flutter, FlutterFire or Xcode? How to read the real error, then fix CocoaPods, deployment target and plugin mismatches.** Read more **](https://app369.com/blog/flutter-ios-build-failed-after-upgrade-2026/)