nexa-sdk icon indicating copy to clipboard operation
nexa-sdk copied to clipboard

[Android] Symbol resolution error in 0.0.13: "cannot locate symbol ggml_argsort_top_k"

Open bhanuka96 opened this issue 2 weeks ago • 6 comments

Problem

Nexa SDK 0.0.13 crashes on Android with a symbol resolution error when initializing. This is a regression from 0.0.11 which works correctly.

Error

dlopen failed: cannot locate symbol "ggml_argsort_top_k" referenced by "/data/app/.../lib/arm64/libnexa_cpu_gpu.so"...

Stack Trace

java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "ggml_argsort_top_k" at com.nexa.sdk.NexaSdk.init(NexaSdk.kt:21)

Analysis

  • libnexa_cpu_gpu.so references ggml_argsort_top_k (undefined symbol: U)
  • libggml-base.so exports ggml_argsort_top_k (defined symbol: T)
  • The symbol exists but isn't visible during runtime linking

Environment

  • SDK Version: 0.0.13
  • Device: Xiaomi M2012K11AG (Snapdragon)
  • Android Version: 13 (API 33)
  • Target SDK: 36

Reproduction

  1. Add implementation("ai.nexa:core:0.0.13") to build.gradle
  2. Call NexaSdk.getInstance().init(context)
  3. App crashes with symbol resolution error

Attempted Workarounds

Pre-loading libraries doesn't help due to namespace isolation:

System.loadLibrary("ggml-base")
System.loadLibrary("ggml-cpu")
System.loadLibrary("nexa_bridge")
// Still fails when loading libnexa_cpu_gpu.so

Workaround

Downgrading to 0.0.11 resolves the issue:
implementation("ai.nexa:core:0.0.11")

Expected Behavior

SDK should initialize without symbol resolution errors, as it did in 0.0.11.

Suspected Root Cause

Possible build configuration issue in 0.0.13:
- Missing DT_NEEDED entry for libggml-base.so in libnexa_cpu_gpu.so
- Or incorrect linker flags during native library build

Related

Related to #886 (16KB page alignment), but this is a separate symbol linking issue in 0.0.13.

Request

Please fix the symbol visibility/linking in 0.0.13 and ensure native dependencies are properly declared.

bhanuka96 avatar Dec 09 '25 10:12 bhanuka96

I have not reproduced your issue. Additionally, why did you use the ndk r28? This is not necessary for this sdk.

nfl-nexa avatar Dec 11 '25 03:12 nfl-nexa

Make it what it should be

Keith cox

On Wed, Dec 10, 2025 at 10:42 PM nfl-nexa @.***> wrote:

nfl-nexa left a comment (NexaAI/nexa-sdk#915) https://github.com/NexaAI/nexa-sdk/issues/915#issuecomment-3639938079

I have not reproduced your issue. Additionally, why did you use the ndk r28?

— Reply to this email directly, view it on GitHub https://github.com/NexaAI/nexa-sdk/issues/915#issuecomment-3639938079, or unsubscribe https://github.com/notifications/unsubscribe-auth/BN5OQI46LZ2APEY4LLKFIH34BDRZ5AVCNFSM6AAAAACOPJAYVGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTMMZZHEZTQMBXHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

keithem avatar Dec 11 '25 04:12 keithem

I have not reproduced your issue. Additionally, why did you use the ndk r28? This is not necessary for this sdk.

It's not related to r28, I tried without it. the error still occurs. The error happens inside NexaSdk.init() when it tries to load the plugin:

NexaSdk: Loading plugin: libnexa_plugin_cpu_gpu.so NexaSdk: dlopen failed: cannot locate symbol "ggml_argsort_top_k" referenced by "libnexa_cpu_gpu.so" RuntimeException: Cannot find cpu_gpu in /data/app/.../lib/arm64

bhanuka96 avatar Dec 12 '25 16:12 bhanuka96

I have not reproduced your issue. Additionally, why did you use the ndk r28? This is not necessary for this sdk.

It's not related to r28, I tried without it. the error still occurs. The error happens inside NexaSdk.init() when it tries to load the plugin:

NexaSdk: Loading plugin: libnexa_plugin_cpu_gpu.so NexaSdk: dlopen failed: cannot locate symbol "ggml_argsort_top_k" referenced by "libnexa_cpu_gpu.so" RuntimeException: Cannot find cpu_gpu in /data/app/.../lib/arm64

Working fine with 0.0.11.

bhanuka96 avatar Dec 12 '25 16:12 bhanuka96

@nfl-nexa plz reproduce and follow

zhiyuan8 avatar Dec 17 '25 04:12 zhiyuan8

@nfl-nexa @zhiyuan8

Update: The symbol resolution issue still exists in version 0.0.15

Error Details:

Same error as originally reported, now occurring with ai.nexa:core:0.0.15:

NexaSdk: Loading plugin: libnexa_plugin_cpu_gpu.so NexaSdk: dlopen failed: cannot locate symbol "ggml_argsort_top_k" referenced by "libnexa_cpu_gpu.so" RuntimeException: Cannot find cpu_gpu in /data/app/.../lib/arm64

Stack Trace (0.0.15):

java.lang.RuntimeException: Cannot find cpu_gpu in /data/app/.../lib/arm64 at com.nexa.sdk.NexaSdk.init(NexaSdk.kt:21) at com.freeai.chat.data.inference.NexaInferenceEngine.ensureSdkInitialized

bhanuka96 avatar Dec 17 '25 08:12 bhanuka96

The SDK has been updated to version 0.0.16. Please upgrade and try again.Now, the SDK initialization has added context environment checking.You can determine whether the initialization was successful by calling NexaSdk.getInstance().init(context, .InitCallback).

nfl-nexa avatar Dec 24 '25 03:12 nfl-nexa