Skip to content

LiteRT: Native-Bibliothek vor Gemma‑4-Engine laden#77

Open
Android-PowerUser wants to merge 10 commits intoadd-gemma-4-e4b-it-integration-neat1yfrom
fix-native-library-loading-issue
Open

LiteRT: Native-Bibliothek vor Gemma‑4-Engine laden#77
Android-PowerUser wants to merge 10 commits intoadd-gemma-4-e4b-it-integration-neat1yfrom
fix-native-library-loading-issue

Conversation

@Android-PowerUser
Copy link
Copy Markdown
Owner

Motivation

  • Beim Start des Gemma‑4 Offline-Modells trat ein JNI-Fehler (nativeCheckLoaded / "No implementation found ...") auf; diese Änderung stellt sicher, dass die LiteRT-JNI-Bibliothek geladen ist, bevor die Engine initialisiert wird.

Description

  • Importiert NativeLibraryLoader, ergänzt das Flag liteRtNativeLoaded und fügt ensureLiteRtNativeLoaded() hinzu, das NativeLibraryLoader.INSTANCE.load() aufruft und bei Fehlschlag als Fallback System.loadLibrary("litertlm_jni") verwendet, und ruft diese Funktion vor Engine(engineConfig).initialize() auf.

Testing

  • Automatisierte Tasks ./gradlew :app:lintDebug und ./gradlew :app:assembleDebug wurden ausgeführt und schlugen fehl wegen fehlender Android SDK-Konfiguration (SDK location not found), daher konnten die Builds in dieser Umgebung nicht erfolgreich abgeschlossen werden.

Codex Task

Copy link
Copy Markdown
Contributor

@amazon-q-developer amazon-q-developer bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes correctly address the JNI loading issue for the Gemma 4 offline model by ensuring the LiteRT native library is loaded before engine initialization. The implementation follows best practices with proper state tracking, error handling via runCatching, and a fallback mechanism.

Key improvements:

  • Added NativeLibraryLoader import and state flag
  • Implemented ensureLiteRtNativeLoaded() with primary load via NativeLibraryLoader.INSTANCE.load() and fallback to System.loadLibrary()
  • Called before Engine(engineConfig).initialize() to prevent JNI errors

The code is well-structured and should resolve the "No implementation found" error mentioned in the PR description.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant