# Frida Termux Compilation Recipe Session: 2026-06-26 Context: Android 16 (Pixel 10 Pro Fold), Termux, Magisk root ## Problem Installing frida Python client on Android/Termux requires compiling the C extension. The build needs: 1. frida-core-devkit (matching frida-server version) 2. meson build system 3. ninja build tool 4. Various dependencies (glib, libffi, pkg-config) ## Step-by-Step Compilation ### 1. Install Dependencies ```bash pkg install clang make pkg-config glib libffi pip install meson ``` ### 2. Compile ninja from Source (Android Bionic Fix) Standard ninja binaries don't work on Android Bionic. Must compile from source with patches. ```bash # Download ninja source curl -L -o ninja-src.tar.gz \ "https://github.com/ninja-build/ninja/archive/refs/tags/v1.12.1.tar.gz" tar -xzf ninja-src.tar.gz cd ninja-1.12.1 # Patch src/util.cc for Android Bionic # Bionic lacks sysinfo structure and SI_LOAD_SHIFT # Replace the GetLoadAverage() function: sed -i 's/#elif defined(__UCLIBC__) || (defined(__BIONIC__) \&\& __ANDROID_API__ < 29)/#elif defined(__UCLIBC__) || defined(__BIONIC__)/' src/util.cc # Then manually edit src/util.cc to replace GetLoadAverage() with: # double GetLoadAverage() { # return -0.0f; # } python3 configure.py --bootstrap cp ninja $PREFIX/bin/ ninja --version # Should show 1.12.1 ``` ### 3. Download Matching frida-core-devkit **CRITICAL**: frida-server and frida Python must be same version. ```bash VERSION=17.15.3 curl -L -o frida-core-devkit-${VERSION}-android-arm64.tar.xz \ "https://github.com/frida/frida/releases/download/${VERSION}/frida-core-devkit-${VERSION}-android-arm64.tar.xz" tar -xf frida-core-devkit-${VERSION}-android-arm64.tar.xz # Produces: libfrida-core.a, frida-core.h, frida-core-example.c ``` ### 4. Download frida Python Source ```bash pip download frida==${VERSION} --no-deps -d frida_wheel cd frida_wheel tar -xzf frida-*.tar.gz ``` ### 5. Compile Python Extension ```bash mkdir frida_build && cd frida_build # Create meson.build pointing to downloaded sources # See SKILL.md for full meson.build template meson setup build meson compile -C build # Output: build/_frida.abi3.so (should be ~130MB) ``` ### 6. Install frida Python Package ```bash cd frida-${VERSION} FRIDA_EXTENSION=/path/to/frida_build/build/_frida.abi3.so \ pip install . --no-build-isolation # Verify python3 -c "import frida; print(frida.__version__)" ``` ### 7. Upgrade frida-server (if needed) ```bash # Download matching frida-server curl -L -o frida-server-${VERSION}-android-arm64.xz \ "https://github.com/frida/frida/releases/download/${VERSION}/frida-server-${VERSION}-android-arm64.xz" unxz frida-server-${VERSION}-android-arm64.xz # Install and restart su -c "cp frida-server-${VERSION}-android-arm64 /data/local/tmp/frida-server.new" su -c "chmod 755 /data/local/tmp/frida-server.new" su -c "killall frida-server" su -c "cp /data/local/tmp/frida-server.new /data/local/tmp/frida-server" su -c "/data/local/tmp/frida-server -D" ``` ## Common Errors and Fixes ### Error: `sysinfo` has no member named `loads` - **Cause**: Android Bionic libc doesn't have full sysinfo structure - **Fix**: Patch ninja's `src/util.cc` as described above ### Error: `SI_LOAD_SHIFT` undeclared - **Cause**: Android Bionic doesn't define SI_LOAD_SHIFT - **Fix**: Same patch as above ### Error: frida Python extension compiles but `import frida` fails - **Cause**: frida-core-devkit version doesn't match frida Python version - **Fix**: Download matching versions from GitHub releases ### Error: Java VM not available after attach - **Cause**: frida-server version mismatch with Python client - **Fix**: Upgrade frida-server to match Python client version ### Error: Process shows as "mmd" instead of "com.tencent.mm" - **Cause**: frida-server version mismatch or multi-process app - **Fix**: Match versions, try different PIDs, or use spawn instead of attach ## Version Compatibility Matrix | frida-server | frida Python | Status | |--------------|--------------|--------| | 17.9.10 | 17.15.3 | ❌ Java VM unavailable | | 17.15.3 | 17.15.3 | ✅ Working | ## Key Takeaways 1. Always match frida-server and frida Python versions exactly 2. Android Bionic requires patching ninja source 3. Java VM availability depends on version matching 4. Process names may differ from package names (e.g., "mmd" vs "com.tencent.mm") 5. /data/local/tmp needs write access for frida helper files