[英]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请检查以下项目
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。
Check the compileSdkVersion
and targetSdkVersion
in your android/app/build.gradle
file.检查android/app/build.gradle
文件中的compileSdkVersion
和targetSdkVersion
。
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.