Running LLM Apps on 32-bit Devices: ABI Adaptation and Native Library Porting Explained
Most AI chat applications ship only arm64-v8a builds, leaving 32-bit Android devices unable to install or run them. This article explains the root cause through Android's ABI mechanism, walks through the core workflow of porting native libraries to armeabi-v7a—including dependency analysis, NDK cross-compilation, self-contained packaging, and re-signing—and covers common pitfalls, validation steps, and more sustainable alternatives like multi-ABI builds and cloud-based inference.
Running LLM Apps on 32-bit Devices: ABI Adaptation and Native Library Porting Explained
1. Background: Why LLM Apps Usually Ship 64-bit-Only Packages
Cloud-based AI chat applications have proliferated in recent years. To get better memory management and execution performance, most of them package only a single ABI (Application Binary Interface): arm64-v8a. This means every native dynamic library (.so file) inside the app is compiled for the 64-bit instruction set.
In reality, however, a considerable number of legacy devices still support only 32-bit instruction sets (such as armeabi-v7a), and some special-purpose devices, older tablets, or custom terminals cannot install 64-bit-only apps. When users try to install such an app on a 32-bit system, the installer either fails outright due to an ABI mismatch, or the app crashes on launch because the native libraries for that architecture cannot be found.
This has led to a common community workaround: porting the app’s native libraries to fill in the missing 32-bit components, so the app can run standalone without depending on any external service framework. This article uses that practice as a starting point to analyze the underlying principles, steps, and caveats from a technical perspective.
2. Android’s ABI Mechanism: Understanding the Root Cause
1. What Is an ABI
An ABI defines the interface contract between binary code and the operating system, covering the instruction set, byte order, calling conventions, dynamic linking format, and more. Common Android ABIs include:
- armeabi-v7a: 32-bit ARM instruction set, with NEON vector extensions;
- arm64-v8a: 64-bit ARM instruction set, i.e., AArch64;
- x86 / x86_64: mainly found in emulators and a small number of devices.
2. How an App Selects an ABI
In a standard APK, native libraries live under lib/<abi>/. At install time, the system picks the matching directory based on the device’s supported ABI list and extracts the corresponding libraries. If the APK contains no directory for the ABI the device needs, two things can happen:
- If the app has no special configuration such as
android:extractNativeLibsand no matching ABI, installation or runtime will fail directly; - Some devices have a “secondary ABI” fallback mechanism—for example, a 64-bit device can fall back to running 32-bit libraries. But the reverse is impossible: a 32-bit device cannot execute 64-bit libraries. This is a hard limitation at the hardware instruction-set level.
That is the fundamental reason a 64-bit-only app cannot run on a 32-bit device: it is not a permission or signature problem—the binary instructions simply cannot be executed.
3. The Core Porting Approach: Filling In the 32-bit Libraries
1. Principle Overview
Porting essentially comes down to one question: for every native library the app depends on, can you find or build an equivalent 32-bit version?
Concretely, you need to do three things:
- Dependency inventory: Unpack the APK, list all .so files under
lib/arm64-v8a/along with their exported symbols, and determine which ones are core app dependencies and which are compute libraries bundled with the inference framework; - Source acquisition: These libraries typically come from open-source inference frameworks, compression libraries, networking libraries, and so on. Obtain the matching source versions and check whether 32-bit build support is still maintained;
- Cross-compilation: Use the NDK to build for the armeabi-v7a target, then add or replace the libraries in the APK’s
lib/armeabi-v7a/directory.
2. Cross-Compilation Example
A typical NDK standalone toolchain build looks like this:
# Set up the 32-bit cross-compilation environmentexport TOOLCHAIN=$NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64export CC=$TOOLCHAIN/bin/armv7a-linux-androideabi21-clangexport CXX=$TOOLCHAIN/bin/armv7a-linux-androideabi21-clang++export CFLAGS="-march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=softfp -O2"# Run the project's own build script, targeting the 32-bit ABIcmake -B build \-DCMAKE_TOOLCHAIN_FILE=$NDK_HOME/build/cmake/android.toolchain.cmake \-DANDROID_ABI=armeabi-v7a \-DANDROID_PLATFORM=android-21 \-DANDROID_NDK=$NDK_HOMEcmake --build build
Flags such as -mfpu=neon-vfpv4 determine whether NEON instructions are enabled, which significantly affects the performance of inference-oriented compute libraries. Adjust them based on what your target devices actually support.
3. Java/Kotlin-Layer Compatibility Checks
Once the native libraries are ported, check the Java layer for architecture-dependent logic, such as:
- Code that branches on
Build.SUPPORTED_ABIS; - The call order of
System.loadLibrary(); - Data structures that assume a 64-bit memory address model (rare, but if present, pointer-width adaptation is needed at the JNI layer).
4. Removing External Service Dependencies: Why Self-Contained Packaging Matters
Many original distribution packages host some components in an external service framework (e.g., relying on a unified push service or an app store distribution channel). A key goal of a ported build is to be fully self-contained:
- All native libraries ship inside the APK, and the runtime never requests injection from any external framework;
- Remove any signature verification or channel-detection logic tied to a specific distribution channel (if present);
- Network requests go directly to the app’s own endpoints, with no intermediary proxy.
The benefit: the ported package can be sideloaded on any standard Android environment without depending on any third-party runtime, and it avoids crashes caused by external service version drift.
Note that any modification to the APK requires re-signing. Use a self-signed certificate to apply v1/v2 signatures, and be aware that different Android versions validate signature schemes differently.
5. Validation and Common Pitfalls
1. Functional Verification Checklist
- Does a cold start work? Use
UnsatisfiedLinkErrorto pinpoint missing libraries; - Are core features such as chat and streaming output functional?
- Does prolonged running cause memory issues? (A 32-bit process address space is only about 3–4 GB, far smaller than 64-bit);
- Test on 32-bit devices with different RAM capacities—low-memory devices are far more likely to hit OOM.
2. Typical Pitfalls
- Missing symbols: Some libraries are built with
-fvisibility=hidden; after porting, JNI symbols can’t be found. Check the export configuration; - Version drift: If the ported library version doesn’t match what the APK’s Java layer expects, JNI method signatures won’t line up and you’ll get
NoSuchMethodErrorat runtime; - Third-party closed-source components: If the app contains closed-source native libraries whose source you can’t obtain, a 32-bit port is essentially infeasible within compliance boundaries. This is the key dividing line for whether such an effort can succeed.
6. Alternatives and a Compliance Reminder
If porting isn’t the route you want, there are several general-purpose alternatives:
- Cloud inference + lightweight client: Put the compute on the server side (e.g., a cloud-based model inference service) and keep the client to UI and networking only—naturally compatible with low-spec devices;
- Rebuild the app with a framework that supports multi-ABI builds: If the app is your own, simply add the
armeabi-v7atarget to your build configuration, for example in Gradle:
android {defaultConfig {ndk { abiFilters 'arm64-v8a', 'armeabi-v7a' }}}
- Web access: Some AI chat services offer a web version, so 32-bit devices can use them through a browser with zero compatibility burden.
Finally, an important reminder: modifying someone else’s app package raises software licensing questions, and the compliance boundaries for personal study versus public distribution are completely different. In real projects, the recommended approach is to maintain multi-ABI builds from day one in your own apps, or rely on mature cloud model services (such as AI coding and chat platforms) to lower client-side resource requirements—avoiding the 32-bit adaptation problem at the source.
7. Conclusion
Getting a 64-bit-only app to run on a 32-bit device is fundamentally an ABI-level binary adaptation effort: analyze dependencies, cross-compile, package self-contained, re-sign, and validate thoroughly. It touches deep knowledge of Android’s loading mechanism, the NDK toolchain, and JNI contracts, making it a valuable hands-on exercise. In production, however, multi-ABI builds and cloud-based inference are the more sustainable and compliant long-term solutions.
