Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Gradle cannot create LibraryVariantBuilderImpl in a Flutter Android build

ErrorCould not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl

Short answer

This error appears when the Android Gradle plugin (AGP) cannot run in the Gradle or IDE you use. Check three version pairs: the Gradle wrapper must meet the minimum for your AGP, Android Studio must support your AGP, and the AGP version should be fixed, not a dynamic range like 8.+.

  • Applies to Flutter 3.3x stable, AGP 8.x and 9.x, Gradle 8.x and 9.x, Android Studio 2026.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the Gradle version the wrapper uses and the AGP version declared in your project, then compare them to the table in the AGP release page. Flutter can also do the comparison for you.

    cd android && ./gradlew --version
    grep -rn "com.android" settings.gradle* build.gradle*
    grep distributionUrl gradle/wrapper/gradle-wrapper.properties
    cd .. && flutter analyze --suggestions
  2. 2Match what you see, then jump to its fix

    1. 1gradlew --version prints a Gradle below the minimum for the AGP version in settings.gradle(.kts)The Gradle wrapper is older than your AGP requiresFix
    2. 2The error shows only inside the IDE, or the IDE asks you to update AGP on opening the projectAndroid Studio is too old for the AGP versionFix
    3. 3A version string such as 8.+ or 9.5.+ in the plugin declarationThe AGP version is a dynamic range, so it changed under youFix

What does the error look like?

  • Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl

Cause 1 of 3

The Gradle wrapper is older than your AGP requires

1Check

Each AGP has a minimum Gradle: for example AGP 8.13 needs 8.13, AGP 9.0 needs 9.1.0 and AGP 9.3 needs 9.5.0. Compare your two versions to the table.

grep distributionUrl android/gradle/wrapper/gradle-wrapper.properties

2Fix

Raise the wrapper to the version flutter analyze --suggestions names, or at least the AGP minimum. Flutter documents this command; run it twice if you also want the wrapper scripts themselves updated.

cd android
./gradlew wrapper --gradle-version=SOMEGRADLEVERSION

3Verify

Rebuild from the project root.

flutter clean && flutter build apk --debug

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 3

Android Studio is too old for the AGP version

1Check

Each Android Studio release supports a range of AGP versions, for example Otter 3 Feature Drop supports 4.2 to 9.0. A project newer than the IDE range can fail to sync.

grep -rn "com.android.application" android/settings.gradle*

2Fix

Update Android Studio to a release whose range includes your AGP, or lower the AGP version in settings.gradle(.kts) and use a Gradle that suits it.

# android/settings.gradle.kts, plugins block
id("com.android.application") version "8.13.0" apply false

3Verify

Sync Gradle in the IDE and run the build once more.

flutter build apk --debug

Confirmed by developer.android.com

Did this fix it?

Cause 3 of 3

The AGP version is a dynamic range, so it changed under you

1Check

Android's docs advise against dynamic versions, which can bring unexpected updates and make version mismatches hard to find.

grep -rn "[0-9]\.+" android/*.gradle* android/settings.gradle*

2Fix

Write one exact AGP version and keep the Gradle wrapper at or above its minimum.

id("com.android.application") version "8.13.0" apply false

3Verify

Run a clean build.

flutter clean && flutter build apk --debug

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Upgrade AGP and the Gradle wrapper in the same commit.
  • Run flutter analyze --suggestions after every Flutter upgrade.
  • Never use + in plugin versions.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

Google Play says the app does not support 16 KB memory pages

check_elf_alignment.sh reports UNALIGNED for a library under lib/arm64-v8a

Google Play requires apps that target Android 15 or higher and ship native .so libraries to run on devices with 16 KB memory pages; from 1 February 2027 it will block updates that do not.

5 causes, each with a fix

Mobile apps

Gradle cannot find the Android SDK on this machine

FAILURE: Build failed with an exception. What went wrong: SDK location not found.

Gradle looks for the Android SDK in the sdk.dir line of android/local.properties and in the ANDROID_HOME environment variable, and found neither.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.