MacOS下Visual Studio Code配置.NET 9 MAUI Android开发环境报错求助
MacOS下Visual Studio Code配置.NET 9 MAUI Android开发环境报错求助
大家好,我现在在Mac上用VS Code跑.NET 9 MAUI应用,iOS调试已经顺利搞定了,但Android的配置环节一直卡壳,折腾了好一阵还是没解决,来求助各位大佬!
我已经做了这些操作:
- 安装了Android Studio,接受了所有许可证,还装了几个模拟器
- 下载了Android API 16、15、14的SDK
- 跟着官方文档步骤完成配置,安装了Microsoft JDK
- 在VS Code里通过
Cmd+Shift+P设置Android SDK路径,不管是用环境变量配置还是手动选择本地文件夹,结果都一致报错
每次都会弹出这个错误提示:
Android SDK missing components. Ensure that all required parts of the Android SDK are installed and up to date. Click to select a valid SDK from your machine. View output for more information. If you are sharing the Android SDK location with Android Studio, the recommended way to install/update the SDK and accept licenses is by using Android Studio.
查看详细输出后,环境状态检测的具体内容如下:
ANDROID ENVIRONMENT STATUS: 28/08/2025, 12:25:28 Here is the status of your Android development environment: Required components: ✓ Java SDK - INSTALLED (version '21.0.8') - Path: '/Library/Java/JavaVirtualMachines/microsoft-21.jdk/Contents/Home' (Workload) - Recommended detected locations: - '/Library/Java/JavaVirtualMachines/jdk-24.jdk/Contents/Home' (VSCode settings) ✗ Android SDK - UPDATE REQUIRED - Path: '/Users/enrico/Library/Android/sdk' (Workload) - Other detected Android SDK locations: - '/Library/Java/JavaVirtualMachines/microsoft-21.jdk/Contents/Home/bin' (VSCode settings) ✓ platforms/android-35 - INSTALLED (version '2') ✓ build-tools/35.0.0 - INSTALLED (version '35.0.0') ✓ platform-tools - INSTALLED (version '36.0.0') ✗ cmdline-tools/12.0 - NOT INSTALLED Optional components: ✓ Android Virtual Device (AVD) - COMPLETE - AVD Path: '/Users/enrico/.android/avd' - AVD devices - DETECTED ('Pixel8') ✓ emulator - INSTALLED (version '36.1.9') ✓ system-images/android-35/google_apis/arm64-v8a - INSTALLED (version '9') ✓ system-images/android-34/google_apis_playstore/arm64-v8a - INSTALLED (version '14') IMPORTANT: - If you are sharing the Android SDK location with Android Studio, the recommended way to install/update the SDK and accept licenses is by using Android Studio. ACTION REQUIRED: ✗- Android SDK - Ensure that the required Android SDK components are installed: "cmdline-tools/12.0". 1. Install the Android SDK components: - From the command palette, choose '.NET MAUI: Configure Android', select 'How to configure Android', and follow the instructions. Take into account that the .NET MAUI Android SDK recommends specific component versions and if you decide to not use them the building and debugging may not work well. Xcode: - Location: /Applications/Xcode.app - Discovered from: xcode-select -p - Installed: true Emulator Pixel 8 (identifier: emulator-5554) is running.
除此之外还有两个衍生问题:
- 模拟器能正常打开,但调试时仍报错「Debugging can fail: Android SDK required components need to be installed」
- VS Code提示「Configuration 'C#: LanguageInUse [Pixel 8]' is missing in 'launch.json'」,我也找不到对应的命令行配置选项
试过各种方法都没搞定,有没有遇到过类似问题的朋友能给点解决思路?谢谢大家!
内容来源于stack exchange
相关产品推荐
相关产品推荐

