8000 Flutter Build Fails Due to AGP 8.4.0 Resolution Issue · Issue #170893 · flutter/flutter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Flutter Build Fails Due to AGP 8.4.0 Resolution Issue #170893
Closed as not planned
Closed as not planned
@WilliamSamson

Description

@WilliamSamson

Steps to reproduce

  1. Create a new Flutter project using flutter create test_flutter
  2. Open the project in Android Studio
  3. Attempt to build or sync the Android project (e.g. flutter build apk --release)
  4. Observe failure during Gradle sync due to unresolved dependency

Expected results

The project should build successfully with the default configuration and toolchain provided by the latest version of Android Studio.

Actual results

Flutter fails to build Android project due to an unresolved version of the Android Gradle Plugin (AGP). Error points to a missing gradle-8.4.0.pom file during project sync.

Build fails with the following error:

FAILURE: Build failed with an exception.

- Where:
Settings file '/home/user/test_flutter/android/settings.gradle.kts' line: 19
- What went wrong:
Error resolving plugin [id: 'dev.flutter.flutter-plugin-loader', version: '1.0.0']

> A problem occurred configuring project ':gradle'.
Could not resolve all artifacts for configuration 'classpath'.
Could not find com.android.tools.build:gradle:8.4.0.
Searched in the following locations:
- https://plugins.gradle.org/m2/com/android/tools/build/gradle/8.4.0/gradle-8.4.0.pom
Required by:
project :gradle
> 
- Try:

> If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
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.
Get more help at https://help.gradle.org/.
> 

BUILD FAILED in 2s
Running Gradle task 'assembleRelease'...                         2,996ms
Gradle task assembleRelease failed with exit code 1

Even a fresh project with no custom modifications fails using Android Studio Meerkat (with Java 21).

Code sample

Code sample
// main.dart from fresh flutter create project

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: Scaffold(
        appBar: AppBar(title: const Text('Demo')),
        body: const Center(child: Text('Hello, Flutter')),
      ),
    );
  }
}
build.gradle.kts
allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get()
rootProject.layout.buildDirectory.value(newBuildDir)

subprojects {
    val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
    project.layout.buildDirectory.value(newSubprojectBuildDir)
}

subprojects {
    project.evaluationDependsOn(":app")
}

tasks.register<Delete>("clean") {
    delete(rootProject.layout.buildDirectory)
}
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.0"
    id("com.android.application") version "8.7.3" apply false
    id("org.jetbrains.kotlin.android") version "2.1.0" apply false
}

include(":app")

Screenshots or Video

Screenshots / Video demonstration

Not applicable

Logs

Logs
FAILURE: Build failed with an exception.

* Where:
Settings file '/home/user/test_flutter/android/settings.gradle.kts' line: 19

* What went wrong:
Error resolving plugin [id: 'dev.flutter.flutter-plugin-loader', version: '1.0.0']

> A problem occurred configuring project ':gradle'.
   Could not resolve all artifacts for configuration 'classpath'.
   Could not find com.android.tools.build:gradle:8.4.0.
     Searched in:
       - https://plugins.gradle.org/m2/com/android/tools/build/gradle/8.4.0/gradle-8.4.0.pom
     Required by:
       project :gradle

BUILD FAILED in 2s
Gradle task assembleRelease failed with exit code 1

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.32.4, on Ubuntu 24.04.2 LTS 6.11.0-26-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2024.3.2)
[✓] IntelliJ IDEA Community Edition (version 2024.3)
[✓] VS Code (version unknown)
✗ Unable to determine VS Code version.
[✓] Connected device (2 available)
[✓] Network resources

No issues found!


</details>

Metadata

Metadata

Assignees

No one assigned

    Labels

    r: invalidIssue is closed as not valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0