A simple Nix setup for Flutter development with Android testing options.
- Flutter and Dart SDK development environment
- Android SDK with build tools
- Two options for testing Android apps:
- Standard Android Emulator (using
default.nix) - Waydroid for native Wayland support (using
flake.nix)
- Standard Android Emulator (using
# Build and run the emulator
nix-build default.nix
./result/bin/run-test-emulator# Setup in NixOS configuration.nix
virtualisation.waydroid.enable = true;
# Enter development environment
nix develop
# Start Waydroid
sudo waydroid init -s GAPPS -f
sudo systemctl start waydroid-container
waydroid session start
waydroid show-full-ui# Create new project
flutter create my_app
cd my_app
# Build your app
flutter build apk
# Install on Android Emulator
adb install build/app/outputs/flutter-apk/app-release.apk
# Or install on Waydroid
waydroid app install build/app/outputs/flutter-apk/app-release.apkIf you have problems with the emulator:
- Try with
JDK8instead ofJDK17if the AVD manager fails - Ensure KVM is enabled:
sudo modprobe kvm - Check virtualization is enabled in BIOS/UEFI
For GPU performance problems:
echo "ro.hardware.gralloc=default
ro.hardware.egl=swiftshader" | sudo tee -a /var/lib/waydroid/waydroid_base.prop