我是新手。我刚刚在flutter中创建了一个新项目,甚至都没有更改代码。 当我运行代码时,出现以下错误。
Launching lib\main.dart on SM A750F in debug mode...
Gradle task assembleDebug failed with exit code -1
Exited (sigterm)
我不知道如何解决这个问题,它搜索了很多方法
当我跑扑医生时,我得到了这个错误,
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.
我不知道这是否与上面的错误有关。
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'
}
预先感谢
答案 0 :(得分:2)
我尝试了从 here 创建的这个,因为我无法通过所有方法让它工作:
在root/android/gradle/wrapper/gradle-wrapper.properties
集合中
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
在root/android/build.gradle
中,设置
dependencies { classpath 'com.android.tools.build:gradle:3.3.2' }
检查 root/android/app/build.gradle
SDK 版本是否设置为最低 28:
compileSdkVersion 28
和 targetSdkVersion 28
这样做后我的项目成功构建
答案 1 :(得分:1)
您需要从Android接受licenes才能运行该应用程序:
运行:
flutter doctor --android-licenses
并接受终端机上的条款
答案 2 :(得分:1)
我没有找到完美的解决方案。 我通过重置窗口解决了该问题。现在已接受所有许可证,并且该应用程序可以正常运行。