如何解决在Flutter中启动应用程序时无法在C:\ Users \ iampr \ AppData \ Local \ Android \ sdk中找到带有哈希字符串'android-27'的目标

如何解决在Flutter中启动应用程序时无法在C:\ Users \ iampr \ AppData \ Local \ Android \ sdk中找到带有哈希字符串'android-27'的目标

问题描述:

PS F:\ flutter \ projects>

PS F:\flutter\projects>

flutter doctor

医生摘要(要查看所有详细信息,请运行flutter doctor -v):

Doctor summary (to see all details, run flutter doctor -v):

[√] Flutter(频道稳定,v1.0.0,在Microsoft Windows [Version 10.0.16299.371],语言环境为美国)

[√] Flutter (Channel stable, v1.0.0, on Microsoft Windows [Version 10.0.16299.371], locale en-US)

[√] Android工具链-为Android设备开发(Android SDK 28.0.3)

[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)

[√] Android Studio(3.2版)

[√] Android Studio (version 3.2)

[√] VS Code,64位版本(1.30.1版)

[√] VS Code, 64-bit edition (version 1.30.1)

[√]已连接设备(1个可用)

[√] Connected device (1 available)

•找不到问题!

PS F:\ flutter \ projects \ demoflutter>

PS F:\flutter\projects\demoflutter>

flutter run

将硬件渲染与针对x86构建的设备Android SDK结合使用.如果您获得图形工件,请考虑使用以下命令启用软件渲染 -启用软件渲染". 在以调试模式为x86构建的Android SDK上启动lib/main.dart ...

Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling software rendering with "--enable-software-rendering". Launching lib/main.dart on Android SDK built for x86 in debug mode...

初始化gradle ... 2.7秒

Initializing gradle...2.7s

正在解决依赖性...

  • 运行Gradle时出错: ProcessException:进程"F:\ flutter \ projects \ demoflutter \ android \ gradlew.bat"异常退出:
    • Error running Gradle: ProcessException: Process "F:\flutter\projects\demoflutter\android\gradlew.bat" exited abnormally:
    • 配置项目:app

      Configure project :app

      在C:\ Users \ iampr \ AppData \ Local \ Android \ sdk \ licenses中检查包Android SDK Build-Tools 28.0.3的许可证

      Checking the license for package Android SDK Build-Tools 28.0.3 in C:\Users\iampr\AppData\Local\Android\sdk\licenses

      已接受Android SDK Build-Tools 28.0.3软件包的许可证.

      License for package Android SDK Build-Tools 28.0.3 accepted.

      准备安装Android SDK Build-Tools 28.0.3(修订:28.0.3)". 准备好安装Android SDK Build-Tools 28.0.3(修订:28.0.3)". 在

      Preparing "Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)". "Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)" ready. Installing Android SDK Build-Tools 28.0.3 in

      C:\ Users \ iampr \ AppData \ Local \ Android \ sdk \ build-tools \ 28.0.3 完成安装Android SDK Build-Tools 28.0.3(修订:28.0.3)". 完成安装Android SDK Build-Tools 28.0.3(修订:28.0.3)".

      C:\Users\iampr\AppData\Local\Android\sdk\build-tools\28.0.3 "Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)" complete. "Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)" finished.

      在C:\ Users \ iampr \ AppData \ Local \ Android \ sdk \ licenses中检查软件包Android SDK Platform 27的许可证 接受Android SDK Platform 27软件包的许可证.

      Checking the license for package Android SDK Platform 27 in C:\Users\iampr\AppData\Local\Android\sdk\licenses License for package Android SDK Platform 27 accepted.

      准备安装Android SDK Platform 27(修订:3)". 准备好安装Android SDK Platform 27(修订:3)".

      Preparing "Install Android SDK Platform 27 (revision: 3)". "Install Android SDK Platform 27 (revision: 3)" ready.

      在中安装Android SDK Platform 27

      Installing Android SDK Platform 27 in

      C:\ Users \ iampr \ AppData \ Local \ Android \ sdk \ platforms \ android-27 完成安装Android SDK Platform 27(修订:3)". 完成安装Android SDK平台27(修订:3)".

      C:\Users\iampr\AppData\Local\Android\sdk\platforms\android-27 "Install Android SDK Platform 27 (revision: 3)" complete. "Install Android SDK Platform 27 (revision: 3)" finished.

      失败:构建失败,并出现异常.

      FAILURE: Build failed with an exception.

      • 其中: 构建文件'F:\ flutter \ projects \ demoflutter \ android \ build.gradle'行:24

      • Where: Build file 'F:\flutter\projects\demoflutter\android\build.gradle' line: 24

      出了什么问题:

      评估根项目"android"时发生问题.

      A problem occurred evaluating root project 'android'.

      配置项目':app'时发生问题. 在以下位置找不到带有哈希字符串"android-27"的目标:C:\ Users \ iampr \ AppData \ Local \ Android \ sdk

      A problem occurred configuring project ':app'. Failed to find target with hash string 'android-27' in: C:\Users\iampr\AppData\Local\Android\sdk

      • 尝试: 使用--stacktrace选项运行以获取堆栈跟踪.使用--info或--debug选项运行,以获取更多日志输出.与--scan一起运行以获取完整信息 见解.

        • 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.

          https://help.gradle.org

          在4m 21s内失败 命令:F:\ flutter \ projects \ demoflutter \ android \ gradlew.bat app:properties

          BUILD FAILED in 4m 21s Command: F:\flutter\projects\demoflutter\android\gradlew.bat app:properties

          请在android/文件夹中查看您的Gradle项目设置. PS F:\ flutter \ projects \ demoflutter>

          Please review your Gradle project setup in the android/ folder. PS F:\flutter\projects\demoflutter>

          这是我的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 27
          
              lintOptions {
                  disable 'InvalidPackage'
              }
          
              defaultConfig {
                  // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
                  applicationId "com.example.demoflutter"
                  minSdkVersion 16
                  targetSdkVersion 27
                  versionCode flutterVersionCode.toInteger()
                  versionName flutterVersionName
                  testInstrumentationRunner "android.support.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 'com.android.support.test:runner:1.0.2'
              androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
          }
          

          单击此处查看android sdk图像

          平台

          构建工具

只需遵循以下四个步骤,这对我有用..

步骤1

步骤2

步骤3

步骤4

这就是所有的输出..!