Android Studio打开已有Flutter应用报错咨询:DART SDK未配置、无设备
Hey there, let's break down how to fix these two frustrating errors when opening an existing Flutter app in Android Studio. I've dealt with these plenty of times, so here's what works reliably:
1. Resolving "DART SDK IS NOT CONFIGURED"
This error usually means Android Studio can't locate your Dart SDK (which comes bundled with the Flutter SDK). Try these steps in order:
Verify Flutter & Dart Plugins Are Installed
Head toFile > Settings > Plugins(Windows/Linux) orAndroid Studio > Settings > Plugins(Mac). Search for "Flutter" and "Dart" — make sure both are installed and enabled. If you just installed them, restart Android Studio to apply changes.Manually Specify the Dart SDK Path
If plugins are set up but the error persists:- Go to
File > Project Structure > Modules - Select your Flutter module from the list
- Look for the "Dart SDK path" field, then navigate to your Flutter installation directory and select the
bin/cache/dart-sdkfolder (this is where the bundled Dart SDK lives) - Click "Apply" and "OK"
- Go to
Use
flutter doctorto Diagnose & Fix
Open your terminal (inside Android Studio or your system terminal) and run:flutter doctorThis command scans your setup and lists any missing components or configuration issues. Follow the prompts — for example, you might need to run
flutter doctor --android-licensesto accept required Android licenses.
2. Fixing "NO DEVICE"
This means Android Studio can't detect any connected physical device or running emulator. Try these fixes:
Set Up a Physical Android Device
- Connect your Android phone to your computer via USB
- Enable Developer Options on your device: Go to
Settings > About Phoneand tap "Build Number" 7 times until you see a message saying "You are now a developer!" - Go back to Settings, open "Developer Options", and toggle on "USB Debugging"
- Check Android Studio's device dropdown (top right corner) — your device should appear now. If not, try unplugging and re-plugging the USB cable, or restarting your device.
Create & Launch an Android Emulator
- Click the "Device Manager" icon (looks like a phone) in the Android Studio toolbar
- Click "Create Virtual Device"
- Choose a device model (like Pixel 5) and click "Next"
- Select a system image (preferably a recent one like API 33 or higher) — if it's not downloaded, click "Download" and wait for it to finish
- Configure any additional settings (like storage) then click "Finish"
- Launch the emulator from Device Manager — once it's running, it should show up in Android Studio's device dropdown.
Check Environment Variables
Make sure your system has these environment variables set:ANDROID_HOME: Points to your Android SDK installation directory (usually~/Android/Sdkon Mac,C:\Users\<YourName>\AppData\Local\Android\Sdkon Windows)PATH: Includes the Flutter bin directory (like~/flutter/binon Mac,C:\flutter\binon Windows)
Runningflutter doctoragain will confirm if these are set correctly.
内容的提问来源于stack exchange,提问作者raman raman

