Skip to content

Fix: Resolve Android cross-compilation failure (Issue #458) - #494

Merged
jongbinjung merged 1 commit into
uber:masterfrom
dyrpsf:fix-android-cross-compile
Jul 13, 2026
Merged

Fix: Resolve Android cross-compilation failure (Issue #458)#494
jongbinjung merged 1 commit into
uber:masterfrom
dyrpsf:fix-android-cross-compile

Conversation

@dyrpsf

@dyrpsf dyrpsf commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #458.

The Problem:
When users attempt to compile h3-py for Android using Buildozer / python-for-android, the build fails at runtime with ImportError: dlopen failed: ... is for EM_X86_64 (62) instead of EM_AARCH64 (183).
Because p4a relies on standard pip install without explicitly passing a CMake toolchain file to scikit-build-core, CMake defaults to building host binaries (x86_64) instead of respecting the target NDK environment.

The Solution:
Added a minimal, non-intrusive environment check in the root CMakeLists.txt just before the project() declaration. If the standard $CC environment variable contains android (which is standard behavior for python-for-android), it automatically sets CMAKE_SYSTEM_NAME to Android.

This forces CMake into cross-compilation mode, allowing it to correctly link against the ARM64 Android NDK without interfering with standard desktop builds (Linux/Mac/Windows).

@dyrpsf dyrpsf mentioned this pull request Jul 7, 2026
@jongbinjung
jongbinjung merged commit 6fd9eff into uber:master Jul 13, 2026
41 checks passed
@jongbinjung

jongbinjung commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Close #458

Thank you @dyrpsf

@dyrpsf

dyrpsf commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Close #458

Thank you @dyrpsf

Thank you! I’m glad this was helpful. Happy to jump back in if any updates are needed.

@dyrpsf
dyrpsf deleted the fix-android-cross-compile branch July 14, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

h3 on Android error

4 participants