简体   繁体   English

在 M1 Macbook 上使用 VSCode 构建 Flutter 项目 Android 时出错

[英]Error when building Flutter project Android with VSCode on M1 Macbook

I'm using M1 Mackbook air.我正在使用 M1 Mackbook air。

This is the result of installing Flutter-related extensions, Android Studio, and Android SDK and running Flutter Doctor.这是安装Flutter相关扩展,Android Studio,Android SDK,运行Flutter Doctor的结果。

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.10, on macOS 12.1 21C52 darwin-arm, locale
    ko-KR)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✗] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS
      development.
      Download at: https://developer.apple.com/xcode/download/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin
        code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To install see
      https://guides.cocoapods.org/using/getting-started.html#installation for
      instructions.
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.74.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

When executing Debug in the lib/main.dart file of the project created using flutter create, the following error appears.在使用flutter create创建的工程的lib/main.dart文件中执行Debug时,出现如下错误。 (the Android emulator specs are: Pixel 4, Android 10) (Android 模拟器规格为:Pixel 4、Android 10)

Launching lib/main.dart on Android SDK built for arm64 in debug mode...                                                                    lib/main.dart:1

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':app:processDebugResources' (type 'LinkApplicationAndroidResourcesTask').
  - In plugin 'com.android.internal.version-check' type 'com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask' property 'androidJarIn 
put.androidJar' specifies file '/Users/gimmingi/Library/Android/sdk/platforms/android-31/android.jar' which doesn't exist.

    Reason: An input file was expected to be present but it doesn't exist.

    Possible solutions:
      1. Make sure the file exists before the task is called.
      2. Make sure that the task which produces the file is declared as an input.
 
    Please refer to https://docs.gradle.org/7.4/userguide/validation_problems.html#input_file_does_not_exist for more details about this problem.

* 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
Exception: Gradle task assemble Debug failed with exit code 1 
Exited

Flutter default project should work in Android emulator. Flutter 默认项目应该在 Android 模拟器中工作。

Please check following items请检查以下项目

  1. As your build is trying to access android version 31 here android-31/android.jar .当您的构建尝试在此处访问 android 版本 31 android-31/android.jar时。 Check if android 31 is installed on your machine.检查您的机器上是否安装了 android 31。

  2. Check the compileSdkVersion and targetSdkVersion in your android/app/build.gradle file.检查android/app/build.gradle文件中的compileSdkVersiontargetSdkVersion

android {
  ...
  compileSdkVersion 31

  defaultConfig{
    ...
      targetSdkVersion 31
    ...
  }
}

Then you can either download the version 31 or change your sdk versions matching your installed sdk versions.然后您可以下载版本 31 或更改您的 sdk 版本以匹配您安装的 sdk 版本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在带有 M1 Pro 芯片的 MacBook 的 android 工作室中运行我的项目 - Can't run my project in android studio in my MacBook with M1 Pro chip Mac m1 flutter 项目未在 Android 设备或模拟器上运行 - Mac m1 flutter project not running on Android device or emulator Macbook M1 上有关 Android Studio 的错误:尝试计算所需的包时发生错误 - Error about Android Studio on Macbook M1: An error occurred while trying to compute required packages 原因:error=86,可执行 M1 Macbook (Android studio) 中的 CPU 类型错误 - Cause: error=86, Bad CPU type in executable M1 Macbook (Android studio) VSCode 和 Android Studio (Flutter) 构建 gradle 时,配置根项目 'android' 时出现问题 - A problem occurred configuring root project 'android' When building the gradle both VSCode and Android Studio (Flutter) 无法在 MacBook M1 芯片上构建 Kotlin 多平台移动项目 - Unable to build Kotlin Multiplatform mobile project on MacBook M1 chip 配备 M1 Max 芯片的新款 MacBook Pro 上的 Android Studio? - Android Studio on new MacBook Pro with M1 Max Chip? 在带有 Apple M1 芯片的 Apple MacBook Pro 中运行“react-native run-android”命令时无法检测到模拟器 - Unable to detect emulator when `react-native run-android` command is ran in Apple MacBook Pro with Apple M1 Chip 无法在 Android Studio 和 Mac M1 中使用 Android 模拟器启动 Flutter 项目 - Can't start Flutter project with Android Emulator in Android Studio and Mac M1 从 Flutter 项目构建 APK 时出错 - Error When Building APK From Flutter Project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM