Flutter error - Gradle task assembleDebug failed with exit code -1
Asked Answered
Q

6

6

I'm new to flutter. I just created a new project in flutter and have not even altered the code. And when I run the code I get the following error.

Launching lib\main.dart on SM A750F in debug mode...
Gradle task assembleDebug failed with exit code -1
Exited (sigterm)

I have no idea how to fix this, searched a number of ways

When I run flutter doctor I get this error,

Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    X Android license status unknown.
      Try re-installing or updating your Android SDK Manager.
      See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup for detailed instructions.

I dont know if this has got anything to do with the error above.

build.gradle(app)

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.dev.teamo"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

Thanks in advance

Quick answered 4/5, 2020 at 2:21 Comment(2)
share your build.gradle app levelMidweek
try the solution in this link https://mcmap.net/q/223860/-first-flutter-app-error-cannot-resolve-symbol-quot-properties-quotSpot
Q
4

I didn't find a perfect solution for this. I solved it by resetting my windows. All licenses are now accepted and the app runs fine.

Quick answered 8/5, 2020 at 4:44 Comment(0)
M
5

You need to accept the licenes from Android to run the app:

run: flutter doctor --android-licenses

And accept the terms on the terminal

Mayamayakovski answered 4/5, 2020 at 3:22 Comment(2)
I've done that.. still it is showing that license status unknownQuick
when i run the command it says 4 license are not accepted and asks if u want to accept.. but doesnt wait to take the input y... It directly exits from the task.. i could only accept it using this command /path-sdk-/tools/bin --licensesQuick
U
5

Delete the .gradle folder then re-run flutter run.

Upsurge answered 12/6, 2022 at 8:6 Comment(0)
Q
4

I didn't find a perfect solution for this. I solved it by resetting my windows. All licenses are now accepted and the app runs fine.

Quick answered 8/5, 2020 at 4:44 Comment(0)
H
4

I tried this as coined from here since I couldn't get it to work from all methods:

  • in root/android/gradle/wrapper/gradle-wrapper.properties set
    distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

  • in root/android/build.gradle, set dependencies { classpath 'com.android.tools.build:gradle:3.3.2' }

  • check if in root/android/app/build.gradle SDK version is set to minimum 28 for: compileSdkVersion 28 and targetSdkVersion 28

My project successfully built after doing this

Helicline answered 19/1, 2021 at 22:21 Comment(0)
P
1

In my case, I was impatient while running the flutter run the first time, and cancelled it, thinking it was stuck. After letting it complete the next time I've started getting the error. Error disappeared after deleting .graddle folder. All i did was:

rm -rf home/$USER/.gradle

After that flutter run worked just fine.

Portwin answered 1/10 at 9:25 Comment(0)
L
0

you can try this way it actually worked for me: 1- visit gradle releases webpage and download last version of gradle 2- unzip the file in this path : "C:\Users"pc name".gradle\wrapper\dists 3- open your editor and try again and it will work inshaalah ☺

Laryngitis answered 14/4, 2022 at 21:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.