skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    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.


  2. i get this proble and solve it with this code added to app/build.gradle

    allprojects {
               .
               .
               .       
          } // keep all project and under it add this code
    ext {
        compileSdkVersion   = 34
        targetSdkVersion    = 34
        appCompatVersion    = "1.7.0" }
    

    and under the :

    rootProject.buildDir = '../build'
    

    add this lines of code :

    subprojects {
        afterEvaluate {
            android {
                compileSdkVersion 34
            }
        }
    }
    

    then run again

    flutter build apk
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search