How to Run Flutter App in VS Code on Linux: Complete Android Development Guide
You can run a Flutter app in VS Code on Linux by installing the Flutter SDK, configuring the Android SDK with ADB, installing the Flutter and Dart VS Code extensions, connecting your Android device via USB with debugging enabled, and pressing F5 to launch the debugger.
To run a Flutter app in VS Code on Linux with a physical Android device, you need to configure the Flutter toolchain, Android Debug Bridge (ADB), and IDE extensions. This guide references the flutter/flutter repository to show you the exact file paths and configurations required to build, deploy, and debug Flutter applications on Linux workstations.
Prerequisites
Install Flutter SDK on Linux
The Flutter SDK contains the flutter command-line tool, the Dart SDK, and platform-specific binaries that drive the Android toolchain. After extracting the SDK, add its bin directory to your PATH so that flutter can be invoked from any terminal.
# Extract Flutter SDK
tar xf flutter_linux_3.x.x-stable.tar.xz
export PATH="$PATH:`pwd`/flutter/bin"
# Verify installation
flutter doctor
The flutter CLI script located at bin/flutter in the SDK root orchestrates the build process, device detection, and deployment.
Configure Android SDK and ADB
Android Studio's SDK manager provides adb, the Android Debug Bridge. With USB debugging enabled on your phone and the device authorized, adb devices lists the phone, allowing the Flutter tool to discover it as a target device.
# Verify device connection
adb devices
# Expected output:
# List of devices attached
# ABC123DEF456 device
Configure VS Code for Flutter Development
Install Flutter and Dart Extensions
The Flutter and Dart extensions add language support, debugging integration, and commands such as Flutter: Launch Emulator and Flutter: Run Without Debugging that internally invoke the flutter CLI.
Install these extensions from the VS Code marketplace:
- Dart (dart-code.dart-code)
- Flutter (dart-code.flutter)
Set Up Launch Configuration
VS Code stores run and debug settings in .vscode/launch.json. A standard Flutter configuration tells VS Code to start flutter run for the currently opened folder and attach the Dart VM debugger.
{
"version": "0.2.0",
"configurations": [
{
"name": "Flutter",
"request": "launch",
"type": "dart"
}
]
}
For a specific device, add the deviceId parameter using the ID from flutter devices:
{
"configurations": [
{
"name": "Flutter on MyPhone",
"request": "launch",
"type": "dart",
"deviceId": "ABC123DEF456"
}
]
}
Connect Your Android Device
Before you run the Flutter app in VS Code on Linux, ensure your Android device is properly configured:
- Enable Developer Options on your Android device (tap Build Number seven times in Settings > About Phone).
- Enable USB Debugging in Developer Options.
- Connect the device via USB and authorize the debugging connection when prompted.
- Verify connectivity with
adb devicesin your terminal.
On Linux, you may need to configure udev rules to allow non-root access to the Android device. Create /etc/udev/rules.d/51-android.rules with your device's vendor ID:
# Example for Google devices
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"
Then reload the rules:
sudo udevadm control --reload-rules
sudo udevadm trigger
Run Flutter App in VS Code on Linux
Using F5 Debug Mode
With the device connected and the Flutter project open, press F5 (or click the green Run button). VS Code reads .vscode/launch.json and runs flutter run in debug mode, attaching the Dart VM debugger to provide breakpoints and inspection tools.
The Flutter tool builds the Android APK using the Gradle configuration in android/gradle.properties and packages/flutter_tools/gradle/flutter.gradle, pushes it to the device via adb, installs it, and starts the Dart VM with a debugging port.
Run Without Debugging
Use the Command Palette (Ctrl+Shift+P) and select Flutter: Run Without Debugging. This launches flutter run in release mode, providing better performance but no debugging capabilities.
Terminal Commands
Open a terminal inside VS Code (Ctrl+``) and execute flutter run manually. This is useful for passing extra flags such as --flavor, --target, or --dart-define:
# Run with a specific flavor
flutter run --flavor development
# Run with environment variables
flutter run --dart-define=API_KEY=12345
Hot Reload and Hot Restart
While the app is running, you can update code instantly without losing app state.
Press r in the integrated terminal where flutter run is active, or click the ⟳ "Hot Reload" button in VS Code. This triggers a quick code push that updates the UI without a full restart.
Press R (capital R) or click the ⭮ "Hot Restart" button to perform a hot restart, which reinitializes the app's state but is faster than a full rebuild and reinstall.
Troubleshooting Common Issues
Device Not Listed
If flutter devices or adb devices does not show your Android phone, ensure the device is unlocked, USB debugging is enabled, and the USB connection is authorized. Run adb kill-server && adb start-server to restart the ADB daemon.
Permission Errors on Linux
If you encounter "no permissions" errors when running adb devices, your user likely lacks access to the USB device. Add a udev rule in /etc/udev/rules.d/51-android.rules with your device's vendor ID, set the mode to 0666, and reload the rules with udevadm control --reload-rules.
Missing Android Toolchain
Run flutter doctor to identify missing components such as adb, Android SDK Platform-Tools, or Android licenses. Install missing components via Android Studio's SDK Manager or the command-line tools, then run flutter doctor --android-licenses to accept the SDK licenses.
Summary
- Install the Flutter SDK on Linux by extracting the archive and adding the
bindirectory to yourPATH, then verify withflutter doctor. - Configure Android SDK and ADB to enable USB debugging on your physical device and ensure
adb deviceslists the phone. - Install VS Code extensions for Flutter and Dart to enable debugging integration and Flutter-specific commands.
- Create
.vscode/launch.jsonwith adarttype configuration to define how VS Code launchesflutter run. - Run the app by pressing F5 for debugging, using the Command Palette for release mode, or executing
flutter runin the terminal. - Use hot reload (
r) and hot restart (R) to update code instantly without full rebuilds. - Troubleshoot device detection, permissions, and toolchain issues using
flutter doctorand udev rules.
Frequently Asked Questions
How do I fix "device not found" when running Flutter in VS Code on Linux?
Ensure USB debugging is enabled on your Android device and that you have authorized the computer on the phone's popup dialog. Run adb devices in your terminal to verify the connection. If the device appears as "unauthorized," disconnect and reconnect the USB cable to trigger the authorization dialog again.
Can I run Flutter apps in VS Code without installing Android Studio?
Yes, you can use the command-line Android SDK tools instead of the full Android Studio IDE. Download the command-line tools from Android's developer site, extract them, and set the ANDROID_SDK_ROOT environment variable. Run flutter doctor to verify the Android toolchain is detected, then install the platform tools and accept licenses using sdkmanager.
Why does my Linux machine require sudo to detect my Android device?
Linux requires udev rules to grant non-root users access to USB devices. Without these rules, adb cannot communicate with the phone unless run with elevated privileges. Create a file at /etc/udev/rules.d/51-android.rules containing a rule with your device's vendor ID (found via lsusb), set the permissions to 0666, and reload the udev rules to resolve this.
How do I specify a particular Android device when multiple are connected?
When multiple devices are connected, VS Code will prompt you to select a target, or you can specify the device ID in your .vscode/launch.json configuration. Add the "deviceId" property with the value from flutter devices output (e.g., "deviceId": "HTC1234567890"). Alternatively, use the terminal command flutter run -d <device_id> to target a specific device directly.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →