Skip to main content
It is possible to build and run the standalone Dart VM for Android devices and emulators.

Limitations

Before you begin, be aware of these limitations:
  • The host (build) machine must be an x64 Linux machine or a Mac
  • The target device must support the Android NDK
  • The Android Dart VM can only be run from the Android command line
  • The Android Dart VM only has access to dart:core APIs - it does not have access to Android C or Java APIs
  • Android-related tools and emulator images require about 2GB of disk space

One-Time Setup

1

Get the Dart source

Download and install the Dart source tree using the standard instructions:
mkdir dart-sdk
cd dart-sdk
fetch dart
See Building from Source for detailed instructions.
2

Configure Android dependencies

Use a text editor to update your .gclient file (located in the directory that contains the main dart directory):
"custom_vars": {
  "download_android_deps": True,
},
Add this to the existing custom_vars section if you already have one, or create the section if it doesn’t exist.
3

Sync Android dependencies

Run gclient sync to download the Android NDK and SDK:
gclient sync
This may take 10 minutes or more depending on your internet connection speed. The download includes the Android NDK, SDK, and build tools.

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:
./tools/build.py --arch=arm64 --os=android runtime

Supported Architectures

The Android Dart VM supports these architectures:
  • arm - 32-bit ARM (armeabi-v7a)
  • arm64 - 64-bit ARM (arm64-v8a)
  • x64 - 64-bit x86
  • riscv64 - 64-bit RISC-V

Build Output

The built Dart VM executables are located at:
out/android/ReleaseAndroidARM/dart      # 32-bit ARM
out/android/ReleaseAndroidARM64/dart    # 64-bit ARM
out/android/ReleaseAndroidX64/dart      # 64-bit x86
out/android/ReleaseAndroidRISCV64/dart  # 64-bit RISC-V

Testing on Android

Add adb to Your PATH

For convenience, add the Android Debug Bridge (adb) tool to your PATH:
export PATH=$PATH:path-to-dart/third_party/android_tools/sdk/platform-tools
Add this to your shell’s rc file (.bashrc, .zshrc, etc.) to make it permanent.

Testing with an Emulator

1

Start an Android emulator

Use the android_finder.py script to start an emulator:
runtime/tools/android_finder.py -a armeabi-v7a -b
Replace 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.
2

Create a directory on the emulator

adb shell mkdir /data/local/tmp/dart
3

Push the Dart VM to the emulator

Copy the Dart executable to the device:
adb push out/android/ReleaseAndroidARM64/dart /data/local/tmp/dart/dart
Adjust the path based on your target architecture:
  • ARM: ReleaseAndroidARM
  • ARM64: ReleaseAndroidARM64
  • X64: ReleaseAndroidX64
  • RISC-V64: ReleaseAndroidRISCV64
4

Create a test script

Create a simple Dart test program:
echo 'main(){ print("Hello, world!");}' > hello.dart
5

Push the test script

Copy the test script to the device:
adb push hello.dart /data/local/tmp/dart
6

Run the Dart VM

Execute your Dart script on Android:
adb shell /data/local/tmp/dart/dart /data/local/tmp/dart/hello.dart
You should see:
Hello, world!

Testing on a Physical Device

1

Enable USB debugging

On your Android device:
  1. Go to Settings > Developer options
  2. Enable “USB debugging”
  3. Connect your device via USB
If you don’t see “Developer options”, go to Settings > About phone and tap “Build number” 7 times.
You may need root access on some devices.
2

Verify device connection

Check that your device is connected:
adb devices
You should see output like:
List of devices attached
TA23701VKR  device
3

Transfer and run

Follow the same steps as for the emulator:
adb -d shell mkdir /data/local/tmp/dart
adb -d push out/android/ReleaseAndroidARM64/dart /data/local/tmp/dart/dart
adb -d push hello.dart /data/local/tmp/dart
adb -d shell /data/local/tmp/dart/dart /data/local/tmp/dart/hello.dart
The -d flag tells adb to use the attached device instead of an emulator.

Multiple Devices

If you have multiple devices or emulators connected, specify which one to use with the -s flag:
# List all devices
adb devices

# Use specific device
adb -s emulator-5554 shell /data/local/tmp/dart/dart /data/local/tmp/dart/hello.dart
adb -s TA23701VKR shell /data/local/tmp/dart/dart /data/local/tmp/dart/hello.dart

Managing Emulators

List Running Emulators

adb devices

Stop an Emulator

adb emu kill

Troubleshooting

Ensure you’ve configured and synced Android dependencies:
  1. Add to .gclient:
    "custom_vars": {
      "download_android_deps": True,
    },
    
  2. Run gclient sync
Add adb to your PATH:
export PATH=$PATH:$(pwd)/third_party/android_tools/sdk/platform-tools
Or use the full path:
./third_party/android_tools/sdk/platform-tools/adb devices
When connecting a device, check the device screen for an authorization prompt. Tap “Allow” to authorize the computer.If the prompt doesn’t appear:
  1. Revoke USB debugging authorizations in Developer options
  2. Disconnect and reconnect the USB cable
  3. Accept the new authorization prompt
Check that hardware acceleration is enabled:
# Linux - check KVM
lsmod | grep kvm

# Mac - check Hypervisor Framework
sysctl kern.hv_support
If KVM is not available on Linux:
sudo apt install qemu-kvm
sudo adduser $USER kvm
# Log out and back in
The /data/local/tmp/ directory should be writable without root. If you get permission errors:
  1. Ensure USB debugging is enabled
  2. Try using adb root (requires rooted device/emulator)
  3. Use a different directory that your app owns

Advanced Usage

Running with Arguments

Pass arguments to your Dart script:
adb shell /data/local/tmp/dart/dart /data/local/tmp/dart/script.dart arg1 arg2

VM Flags

Pass VM flags before the script path:
adb shell /data/local/tmp/dart/dart --enable-asserts /data/local/tmp/dart/script.dart

Accessing Device Files

Your Dart script can read files from the device:
import 'dart:io';

void main() {
  var file = File('/data/local/tmp/dart/data.txt');
  print(file.readAsStringSync());
}
Push the data file:
adb push data.txt /data/local/tmp/dart/

Next Steps

ARM/RISC-V Builds

Cross-compile for ARM and RISC-V Linux

Testing

Learn about testing the Dart SDK

Build docs developers (and LLMs) love