Home > Mobile >  build.gradle error: Could not create tastk ':generateLockfiles'. in Flutter project but Ap
build.gradle error: Could not create tastk ':generateLockfiles'. in Flutter project but Ap

Time:08-15

I have an error in my build.gradle file (android/build.gradle) in my Flutter project. The App is running completely normal but this error is still not looking good to me. Does anyone ever had this problem/error?

enter image description here

enter image description here

Here is my complete build.gradle file:

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.13'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

flutter doctor -v Output:

[√] Flutter (Channel stable, 3.0.5, on Microsoft Windows [Version 10.0.22598.200], locale de-DE)
    • Flutter version 3.0.5 at C:\Flutter\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (5 weeks ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\jjkla\AppData\Local\Android\sdk
    • Platform android-31, build-tools 30.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.10 0-b96-7249189)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 2020.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10 0-b96-7249189)

[√] VS Code (version 1.70.1)
    • VS Code at C:\Users\jjkla\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.46.0

[√] Connected device (2 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 104.0.5112.81
    • Edge (web)   • edge   • web-javascript • Microsoft Edge 104.0.1293.54

[√] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

CodePudding user response:

open your android project in android studio file > open > in your flutter project choose android file then rebuild gradle, I have same problem and solved it like this.

CodePudding user response:

You can do flutter clean and flutter pub get and then try to build again.

  • Related