microsoft / microsoft/onnxruntime-genai
Crash on Android: Ort::InitApi() aborts because libonnxruntime.so resolves to the Linux build, not the Android AAR
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.1k
- Forks
- 354
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 85
Description
Summary
On Android (.NET MAUI, net10.0-android), the app crashes on launch when constructing the first OnnxRuntimeGenAI.Model / InferenceSession, with a native abort inside Ort::InitApi(). Root cause traced to microsoft/onnxruntime — full details and binary-level evidence filed there: https://github.com/microsoft/onnxruntime/issues/29270
In short: the Microsoft.ML.OnnxRuntime NuGet package ships both an Android AAR (runtimes/android/native/onnxruntime.aar) and a desktop Linux build (runtimes/linux-arm64/native/libonnxruntime.so) in the same package version. During Android packaging, the Linux build ends up at the APK path where the Android AAR's library should be. The Linux build depends on glibc-only symbols (libdl.so.2, librt.so.1, libstdc++.so.6, ld-linux-aarch64.so.1) that don't exist on Android/Bionic, so dlopen fails and Ort::InitApi() throws, aborting the process.
Reproduced identically across three version pairs: 0.8.3/1.22.0, 0.12.0/1.24.1, 0.14.0/1.23.0 — see the linked issue for full version matrix, logs, and objdump evidence.
Crash signature
W GenAI : Error while dlopen: dlopen failed: library "libdl.so.2" not found: needed by
.../lib/arm64/libonnxruntime.so in namespace clns-9
I GenAI : Attempting to dlopen .../lib/arm64/libonnxruntime.so.1
W GenAI : Error while dlopen: dlopen failed: library ".../lib/arm64/libonnxruntime.so.1" not found
F DEBUG : #06 pc ... libonnxruntime-genai.so (Ort::InitApi()+784)
F DEBUG : #05 pc ... libonnxruntime-genai.so (__cxa_throw+128)
...
I ActivityManager: Process com.<app> has died: fg TOP
The .so.1 retry is the tell — that's a Linux SONAME-versioning convention, never used on Android.
Environment
- .NET SDK 10.0.203,
Microsoft.Android.Sdk.Darwin36.1.53, macOS host - Real device: Google Pixel 6, Android 16 (API 36), arm64-v8a
Microsoft.ML.OnnxRuntimeGenAIreferenced alongsideMicrosoft.ML.OnnxRuntimevia PackageReference (tested both via a ProjectReference-linked shared library and a direct reference in the Android app project — same result)
Filing here as well since this is where the crash is visible and where the related 16KB-page-size issue (#1928) was tracked — please redirect/close as a duplicate if you'd prefer this be tracked solely on the onnxruntime issue.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked microsoft/onnxruntime issue, then inspect how runtimes/android/native/onnxruntime.aar and runtimes/linux-arm64/native/libonnxruntime.so are packaged into the Android application. Done means Android resolves the AAR's library rather than the Linux build and the reported Ort::InitApi() crash no longer occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, cpp
- Domain
- build-system, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100