Reputation: 803
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
Upvotes: 5
Views: 45128
Reputation: 11
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.
Upvotes: 1
Reputation: 1
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 ☺
Upvotes: 0
Reputation: 259
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
Upvotes: 3
Reputation: 803
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.
Upvotes: 3
Reputation: 1479
You need to accept the licenes from Android to run the app:
run:
flutter doctor --android-licenses
And accept the terms on the terminal
Upvotes: 4