【发布时间】:2021-01-18 07:32:23
【问题描述】:
Flutter 在以前的设备上运行良好。我已经更换了我的笔记本电脑,在完成所有设置后我收到了这个错误,我无法理解这个错误。
-
请解释这个错误的原因。
-
此错误的解决方案
我只是在运行非常基本的应用程序。
app 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 plugin: 'kotlin-android'
> apply from:
> "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
>
> android {
> compileSdkVersion 29
>
> sourceSets {
> main.java.srcDirs += 'src/main/kotlin'
> }
>
> lintOptions {
> disable 'InvalidPackage'
> }
>
> defaultConfig {
> // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
> applicationId "com.example.flutter_app"
> minSdkVersion 16
> targetSdkVersion 29
> versionCode flutterVersionCode.toInteger()
> versionName flutterVersionName
> }
>
> 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 {
> implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" }
android gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Logcat: 请配置Android SDK
终端报告
C:\Users\HP\StudioProjects\flutter_app>flutter run
Using hardware rendering with device sdk gphone x86. If you notice graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib\main.dart on sdk gphone x86 in debug mode...
Checking the license for package Android SDK Build-Tools 28.0.3 in C:\Users\HP\AppData\Local\Android\sdk\licenses
Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
Checking the license for package Android SDK Platform 29 in C:\Users\HP\AppData\Local\Android\sdk\licenses
Warning: License for package Android SDK Platform 29 not accepted.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
platforms;android-29 Android SDK Platform 29
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: C:\Users\HP\AppData\Local\Android\sdk
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 2.5s
Exception: Gradle task assembleDebug failed with exit code 1
颤振医生 - V
[√] Flutter (Channel stable, 1.22.0, on Microsoft Windows [Version 10.0.18362.1082], locale en-US)
• Flutter version 1.22.0 at C:\src\flutter
• Framework revision d408d302e2 (4 days ago), 2020-09-29 11:49:17 -0700
• Engine revision 5babba6c4d
• Dart version 2.10.0
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:\Users\HP\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 50.0.1
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code (version 1.49.2)
• VS Code at C:\Users\HP\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.14.1
[√] Connected device (1 available)
• sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
! Doctor found issues in 1 category.
【问题讨论】:
-
能否提供
flutter doctor -v? -
是的,我用颤振医生 -v 报告编辑问题。
标签: android-studio flutter dart flutter-layout