I have been for the error for an hour and tried multiple gradle packages to rectify this error.But, I don't know what to do .
I have updated my flutter stable.Done all that.But none is working and coming back to where i have started.
Error
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\Github\block_porn\android\app\build.gradle.kts' line: 1
* What went wrong:
An exception occurred applying plugin request [id: 'dev.flutter.flutter-gradle-plugin']
> Failed to apply plugin 'dev.flutter.flutter-gradle-plugin'.
> class com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated_Decorated cannot be cast to class com.android.build.gradle.AbstractAppExtension (com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated_Decorated and com.android.build.gradle.AbstractAppExtension are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader @708305b2)
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights from a Build Scan (powered by Develocity).
> Get more help at https://help.gradle.org.
BUILD FAILED in 1s
4 actionable tasks: 4 up-to-date
JAVA VERSION : java 17.0.11 2024-04-16 LTS
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
android/app/build.gradle.kts
plugins {
id("com.android.application")
id("com.google.gms.google-services")
id("dev.flutter.flutter-gradle-plugin")
id("org.gradle.toolchains.foojay-resolver-convention")
}
android {
namespace = "com.example.block_porn"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
defaultConfig {
applicationId = "com.example.block_porn"
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}
buildTypes {
release {
signingConfig = signingConfigs.getByName("debug")
}
}
}
kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
}
}
flutter {
source = "../.."
}
gradle.properties
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android/settings.gradle.kts
pluginManagement {
val flutterSdkPath =
run {
val properties = java.util.Properties()
file("local.properties").inputStream().use { properties.load(it) }
val flutterSdkPath = properties.getProperty("flutter.sdk")
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
flutterSdkPath
}
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id ("dev.flutter.flutter-plugin-loader") version "1.0.2"
id("com.android.application") version "9.3.0" apply false
id("org.jetbrains.kotlin.android") version "2.4.10" apply false
id("com.android.library") version "9.3.0" apply false
id("com.google.gms.google-services") version("4.4.4") apply false
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
}
include(":app")
Flutter Doctor
flutter doctor -v
[√] Flutter (Channel stable, 3.44.8, on Microsoft Windows [Version 10.0.26200.8973], locale en-IN) [791ms]
• Flutter version 3.44.8 on channel stable at C:\tools\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 058e0af2c2 (7 days ago), 2026-07-23 10:56:21 -0700
• Engine revision 0cd610717b
• Dart version 3.12.2
• DevTools version 2.57.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-swift-package-manager, omit-legacy-version-file,
enable-lldb-debugging, enable-uiscene-migration
[√] Windows Version (11 Home Single Language 64-bit, 25H2, 2009) [4.0s]
[√] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [5.2s]
• Android SDK at C:\Android
• Emulator version 36.6.11.0 (build_id 15507667) (CL:N/A)
• Platform android-36.1, build-tools 36.1.0
• Java binary at: C:\Program Files\Java\jdk-17\bin\java
This JDK is specified in your Flutter configuration.
To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
• Java version Java(TM) SE Runtime Environment (build 17.0.11+7-LTS-207)
• All Android licenses accepted.
[√] Chrome - develop for the web [471ms]
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[!] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.14.33 (May 2026)) [468ms]
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.14.37314.3
X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components:
MSVC v142 - VS 2019 C++ x64/x86 build tools
- If there are multiple build tool versions available, install the latest
C++ CMake tools for Windows
Windows 10 SDK
[√] Connected device (3 available) [706ms]
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.26200.8973]
• Chrome (web) • chrome • web-javascript • Google Chrome 150.0.7871.187
• Edge (web) • edge • web-javascript • Microsoft Edge 150.0.4078.105
[√] Network resources [750ms]
• All expected network resources are available.
! Doctor found issues in 1 category.
I will be glad with knowing the proper compactability version.Every time it is like a mess when i takedown this and it is taking a lot of time.