Most Flutter developers use a PC or Mac as the host machine and connect an Android device for testing. That workflow works well, but it ties you to a separate computer, consumes extra power, and adds a layer of dependency on USB cables or Wi‑Fi ADB. With Termux – a Linux‑like terminal environment that runs on Android without root – you can turn the phone itself into a full‑featured development workstation.
Running Flutter on the device gives you:
flutter run compiles and launches directly on the same device.This tutorial assumes you have a relatively recent Android version (Android 10 or newer) and at least 4 GB of free internal storage. The steps work on most ARM64 devices; for 32‑bit devices replace aarch64 with arm where indicated.
Make sure your device is fully charged (or keep it plugged in) and connected to a stable Wi‑Fi network. The installation will download several hundred megabytes.
termux-setup-storage. Accept the Android prompt.pkg update && pkg upgrade -y
pkg install -y git curl wget unzip zip tar proot-distro
Termux now provides a Debian‑like environment where we can install the Java runtime, Android command‑line tools, and Flutter itself.
Flutter’s Android toolchain relies on Java 11 (or newer). Termux offers OpenJDK packages that work well on ARM64.
pkg install -y openjdk-17
java -version
You should see something like openjdk version "17.x.x".If the command reports command not found, repeat the pkg install step and ensure your PATH includes $HOME/.local/bin (Termux adds it automatically).
The Android SDK provides the adb, sdkmanager, and other utilities that Flutter uses to compile and sign apps.
mkdir -p $HOME/Android/sdk
wget:
wget -O cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip
unzip cmdline-tools.zip -d $HOME/Android/sdk/cmdline-tools
latest so that sdkmanager can find it:
mv $HOME/Android/sdk/cmdline-tools/* $HOME/Android/sdk/cmdline-tools/latest
PATH (add these lines to ~/.bashrc or ~/.zshrc):
export ANDROID_SDK_ROOT=$HOME/Android/sdk
export PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools
Then source the file:
source ~/.bashrc
sdkmanager --sdk_root=$ANDROID_SDK_ROOT "platforms;android-33" "build-tools;33.0.2" "platform-tools" --licenses
Type y when prompted.
At this point adb and sdkmanager should be callable from the terminal.
Flutter provides a pre‑compiled Linux binary that runs perfectly in Termux’s Linux environment.
$HOME/development):
mkdir -p $HOME/development && cd $HOME/development
wget -O flutter_linux.tar.xz https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.22.0-stable.tar.xz
Note: Replace the version number with the most recent stable release if you wish; the URL pattern stays the same.
tar xf flutter_linux.tar.xz
PATH (append to ~/.bashrc):
export PATH=$PATH:$HOME/development/flutter/bin
Then reload:
source ~/.bashrc
flutter doctor to let Flutter download additional components:
flutter doctor
The first run will fetch the Dart SDK and set up the Android toolchain. Follow any prompts to accept licenses.
If flutter doctor reports missing components, run the suggested commands. Typical missing items are the Android SDK (already installed) and the Java version (already set up).
Run flutter doctor -v for a verbose report. A healthy setup should show:
adb found.If you see a warning about Android licenses not accepted, re‑run the sdkmanager --licenses command from Step 3.
Now that the environment is ready, let’s build a tiny “Hello World” app and launch it on the same device.
flutter create hello_flutter
cd hello_flutter
android-tools package (which provides adb) if you haven’t already:
pkg install -y android-tools
adb start-server
adb devices
The output should list a device with the word device next to it. If it shows offline or nothing, make sure USB debugging is enabled and that Termux has the android.permission.USB_PERMISSION (granted automatically when you enable USB debugging).flutter run
Flutter will compile the Dart code, invoke Gradle to build an APK, install it, and launch the app. You should see the familiar “Hello world” screen.
Congratulations – you have just compiled and executed a Flutter app without ever leaving your phone.
One of Flutter’s biggest productivity boosts is hot‑reload. While the app is running, you can edit lib/main.dart with any editor (e.g., vim or nano inside Termux) and press r in the terminal to inject the changes instantly.
Example:
vim lib/main.dart
Change the text inside Text('Hello world') to something else, save, then press r in the running flutter run session. The UI updates without a full rebuild.
Flutter stores downloaded packages in $HOME/.pub-cache and build intermediates in build/ inside each project. Over time these can consume several gigabytes.
flutter pub cache repair (re‑downloads only needed packages).flutter clean.export PUB_CACHE=/sdcard/flutter_pub_cache
Remember to add the export line to your ~/.bashrc.
java.lang.OutOfMemoryError during Gradle buildTermux runs on limited RAM. If the Gradle daemon crashes with an OOM error, increase the heap size for the daemon:
export _JAVA_OPTIONS="-Xmx1024m"
flutter clean && flutter run
Adjust 1024m based on your device’s RAM (e.g., 2048m for a 6 GB device).
adb: command not foundMake sure the android-tools package is installed and that $HOME/Android/sdk/platform-tools is in your PATH. Re‑source your shell configuration or restart Termux.
Flutter pins a specific Gradle wrapper version. If you see a message about an unsupported Gradle version, delete the gradle/wrapper/gradle-wrapper.properties file and let Flutter regenerate it by running flutter pub get again.
Double‑check that ANDROID_SDK_ROOT points to the directory created in Step 3 ($HOME/Android/sdk) and that the platform-tools sub‑folder exists.
This usually means the device cannot reach Google’s Maven repository. Ensure you have a working internet connection, then run:
flutter pub cache repair
flutter clean
flutter run
Compiling Flutter apps is CPU‑intensive. On low‑end devices (e.g., 1 GB RAM, older Snapdragon), a full build may take several minutes. For rapid iteration, rely on hot‑reload as much as possible and keep the codebase small.
Running the Android emulator inside Termux is not feasible; you are limited to the physical device you are using. If you need to test multiple screen sizes, consider using responsive layout techniques inside your Flutter code.
openjdk-17 with openjdk-11 (the last version available for 32‑bit). The Flutter binary still works because it is compiled for x86_64; you must use the flutter_linux_3.22.0-stable.tar.xz “linux‑x64” build, which runs under proot‑distro. The tutorial above assumes ARM64; for 32‑bit you would need to run an x86 chroot, which is beyond the scope of this guide.flutter channel beta followed by flutter upgrade. The steps remain the same.Android/sdk folder to an SD card and update ANDROID_SDK_ROOT accordingly.If you ever need to free up space or start fresh:
rm -rf $HOME/development/flutter
rm -rf $HOME/Android/sdk
pkg uninstall openjdk-17 android-tools git curl wget unzip zip tar proot-distro
All user data (your Flutter projects) remain in whatever folder you created (e.g., $HOME/development/hello_flutter) unless you delete them explicitly.
By following the steps above you have transformed an ordinary Android phone into a self‑contained Flutter development workstation. The process leverages Termux’s Linux environment, open‑source command‑line tools, and Flutter’s own cross‑platform SDK. While the build times on a phone are slower than on a desktop, the convenience of coding, testing, and iterating without a separate computer can be a game‑changer for learning, quick prototyping, or working while traveling.
Feel free to explore further: integrate Git for version control, install a lightweight editor like micro or vim, and experiment with Flutter plugins that access device sensors directly from your Termux‑based setup. Happy coding!









