我是flutter的新手。我刚刚在flutter中创建了一个新项目,甚至没有更改代码。当我运行代码时,我收到以下错误。
Launching lib\main.dart on SM A750F in debug mode...
Gradle task assembleDebug failed with exit code -1
Exited (sigterm)
我不知道怎么解决这个问题我找了很多方法
当我运行flutter医生时,我得到了这个错误,
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(应用程序)
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'
}
提前谢谢
您需要接受来自Android的许可证才能运行该应用程序:
运行:flutter医生--android-许可证
并接受终端上的条款
我没有找到完美的解决方案。我通过重置窗口解决了它。现在接受了所有许可证,应用程序运行良好。
我尝试了从这里创造的,因为我无法从所有方法中得到它:
>
在根/android/gradle/包装器/gradle-wrapper.properties设置分布Url=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
在root/android/build. gradle
中,设置依赖项{classpath'com.android.tools.build:gradle:3.3.2'}
检查在root/android/app/build. gradle
中SDK版本是否设置为最小28:compileSdkVersion 28
和target etSdkVersion 28
我的项目在这样做后成功构建