'Flutter error - Gradle task assembleDebug failed with exit code -1
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
Solution 1:[1]
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.
Solution 2:[2]
You need to accept the licenes from Android to run the app:
run:
flutter doctor --android-licenses
And accept the terms on the terminal
Solution 3:[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
setdistributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
in
root/android/build.gradle
, setdependencies { 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
andtargetSdkVersion 28
My project successfully built after doing this
Solution 4:[4]
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 ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jerin |
Solution 2 | Gerry |
Solution 3 | DuDa |
Solution 4 |