How do I compile XMRig on Android?
You can compile XMRig on many 64-bit Android devices using Termux, an Android app that gives you a Linux-style command line and development tools. This builds a native mining program, not a browser miner, and success depends on your device’s processor, Android version, and available memory.
Check your device first
Only do this on a device you own or have clear permission to use. A spare Android phone or tablet is a better choice than your main phone.
Install a current Termux release from its official F-Droid listing or official GitHub releases. Avoid unofficial APK downloads and outdated installation guides.
Open Termux and run:
uname -m
These steps are intended for devices reporting aarch64, meaning a 64-bit ARM environment. If you see armv7l, you have a 32-bit environment; this is not a suitable route for modern Monero mining.
You also need free storage for the source files and build tools. Several gigabytes of RAM are strongly recommended: RandomX, Monero’s mining algorithm, uses a 2,080 MB dataset in fast mode, plus additional memory. Android needs room too.
Install tools and download XMRig
In Termux, run:
pkg update
pkg upgrade
pkg install git clang cmake make pkg-config libuv openssl
These install a compiler, which turns source code into a runnable program, and the supporting tools and libraries XMRig needs.
Download the official source:
git clone https://github.com/xmrig/xmrig.git
cd xmrig
For a more repeatable build, check XMRig’s official releases and select a published release tag rather than relying on the changing default branch:
git checkout RELEASE_TAG
Replace RELEASE_TAG with a real tag. Never copy mining commands from strangers without checking the wallet address and download source.
Configure and compile
Run these commands inside the xmrig directory:
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DWITH_HWLOC=OFF \
-DWITH_OPENCL=OFF \
-DWITH_CUDA=OFF
cmake --build build -j2
This creates a CPU-only build. It disables GPU mining components and hwloc, a hardware-layout library that can complicate Android builds.
The -j2 option runs two compilation tasks at once. If Android closes Termux or memory runs low, retry with -j1.
Check the result:
./build/xmrig --version
You do not need root access just to compile or run XMRig.
Test gently and handle problems
For a small test, use a mining pool—a service that combines miners’ work and shares rewards:
./build/xmrig \
-o POOL_HOST:PORT \
-u YOUR_MONERO_WALLET_ADDRESS \
-p android \
--coin monero \
-t 1
Replace the placeholders with your pool’s settings and your own wallet address. Follow the pool’s instructions for encrypted connections and any additional options.
Start with one mining thread, meaning one worker task. Stop with Ctrl+C if the device becomes hot.
Common issues include:
- Missing libraries: Confirm the package installation succeeded, then rerun configuration.
- Memory allocation failure: Close other apps. RandomX’s light mode uses a 256 MB cache but is much slower.
- Huge-page warnings: These memory optimizations are generally unavailable in ordinary Android setups.
- Background shutdowns: Android may stop Termux to save battery.
The bottom line
Compiling XMRig on Android is mainly a learning project. Phone mining is usually slow, creates sustained heat, and can accelerate battery wear. Check a live mining calculator rather than expecting meaningful earnings.
