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

2

7 Answers 7

4

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

run: flutter doctor --android-licenses

And accept the terms on the terminal

Sign up to request clarification or add additional context in comments.

2 Comments

I've done that.. still it is showing that license status unknown
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 --licenses
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.

Comments

4

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

Comments

3

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

Comments

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.

Comments

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 ☺

Comments

0

run flutter upgrade then flutter run -d "device name". solved my problem, hope this is helpful to you

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.