androidflutterdartgradle

build failed in flutter build apk


when i run flutter build apk i get this error:

FAILURE: Build failed with an exception.
* What went wrong:
  Could not resolve all files for configuration 'classpath'.
> Could not find lint-model-30.3.0.jar (com.android.tools.lint:lint-model:30.3.0).
> Searched in the following locations:
> https://dl.google.com/dl/android/maven2/com/android/tools/lint/lint-model/30.3.0/lint-model-30.3.0.jar

android/buid.gradle:

    ext.kotlin_version = '1.9.20'
    repositories {
    google()
    jcenter()

    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
    google()
    jcenter()

    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

flutter doctor:

[√] Flutter (Channel stable, 3.16.0, on Microsoft Windows [Version 10.0.19044.3324], locale fa-IR)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.0)
[√] Android Studio (version 2022.2)
[√] VS Code, 64-bit edition (version 1.81.0)
[√] Connected device (4 available)
[√] Network resources

my fluter SDK version is 3.16.0 i also tried with 3.24.3 but results are same.

i tried to create new project but error still exists, windows build is ok.

i also tried to delete gradle cache and pub cache but it just didn't work out.


Solution

  • first i ran this command in console:

    flutter pub cache repair

    then deleted this line of code in android/app build.gradle

    classpath 'com.android.tools.build:gradle:8.1.2'

    and ran this command :

    flutter pub get

    eventually after afew hours of downloading, it fixed.