Limitations
Before you begin, be aware of these limitations:One-Time Setup
Get the Dart source
Download and install the Dart source tree using the standard instructions:See Building from Source for detailed instructions.
Configure Android dependencies
Use a text editor to update your
.gclient file (located in the directory that contains the main dart directory):Add this to the existing
custom_vars section if you already have one, or create the section if it doesn’t exist.Building for Android
Once you’ve set up your build tree, build the Dart VM for Android using the standard build script with the--os android flag:
Supported Architectures
The Android Dart VM supports these architectures:arm- 32-bit ARM (armeabi-v7a)arm64- 64-bit ARM (arm64-v8a)x64- 64-bit x86riscv64- 64-bit RISC-V
Build Output
The built Dart VM executables are located at:Testing on Android
Add adb to Your PATH
For convenience, add the Android Debug Bridge (adb) tool to your PATH:Add this to your shell’s rc file (
.bashrc, .zshrc, etc.) to make it permanent.Testing with an Emulator
Start an Android emulator
Use the Replace
android_finder.py script to start an emulator:armeabi-v7a with your target architecture (armeabi-v7a or x86).The flags:-a: Specifies the architecture to find-b: Bootstrap (start) a new emulator if none exists
This script may take up to 20 seconds if a new emulator needs to be started.
Push the Dart VM to the emulator
Copy the Dart executable to the device:Adjust the path based on your target architecture:
- ARM:
ReleaseAndroidARM - ARM64:
ReleaseAndroidARM64 - X64:
ReleaseAndroidX64 - RISC-V64:
ReleaseAndroidRISCV64
Testing on a Physical Device
Enable USB debugging
On your Android device:
- Go to Settings > Developer options
- Enable “USB debugging”
- Connect your device via USB
If you don’t see “Developer options”, go to Settings > About phone and tap “Build number” 7 times.
Multiple Devices
If you have multiple devices or emulators connected, specify which one to use with the-s flag:
Managing Emulators
List Running Emulators
Stop an Emulator
Troubleshooting
Build fails with missing Android NDK
Build fails with missing Android NDK
Ensure you’ve configured and synced Android dependencies:
-
Add to
.gclient: -
Run
gclient sync
adb: command not found
adb: command not found
Add adb to your PATH:Or use the full path:
adb: device unauthorized
adb: device unauthorized
Emulator won't start
Emulator won't start
Check that hardware acceleration is enabled:If KVM is not available on Linux:
Permission denied on device
Permission denied on device
The
/data/local/tmp/ directory should be writable without root. If you get permission errors:- Ensure USB debugging is enabled
- Try using
adb root(requires rooted device/emulator) - Use a different directory that your app owns
Advanced Usage
Running with Arguments
Pass arguments to your Dart script:VM Flags
Pass VM flags before the script path:Accessing Device Files
Your Dart script can read files from the device:Next Steps
ARM/RISC-V Builds
Cross-compile for ARM and RISC-V Linux
Testing
Learn about testing the Dart SDK