Inspect the real adapter
LocalStoryGenerator serializes work with a Mutex and enters Dispatchers.IO. It creates one Engine for a scene, initializes it, creates a conversation and closes initialized resources after the operation. This avoids overlapping native sessions at the cost of repeated startup work. Reusing an engine would need an explicit lifecycle and memory policy; it is not automatically an optimization on a constrained phone.
EngineConfig(
modelPath = model.file.path,
backend = Backend.GPU(),
visionBackend = Backend.GPU(),
maxNumTokens = 4096,
maxNumImages = 1,
cacheDir = cache.path,
)
This excerpt is the pinned adapter configuration. Both backends are GPU; no CPU fallback is implemented. Initialization is not a proof that conversation allocation or image encoding will work. The observed emulator error occurred later, during vision resource creation.
The input list contains Content.ImageFile for a selected image followed by Content.Text for the prompt. The model generates prose, not a new illustration. The bookshelf cover is a bundled development asset. The conversation uses topK 40, topP 0.9, temperature 0.8, enable_thinking false and maxOutputToken 320. These are sample choices, not a demonstrated optimum or a guarantee of 80–120 words.
Streaming and completion are separate
MessageCallback sends chunks to the ViewModel. A CompletableDeferred represents the terminal callback: onDone completes it and onError completes it exceptionally. A partial draft may exist before either terminal event. It must not automatically become an accepted chapter merely because some text appeared.
Consult the versioned LiteRT-LM API when changing integration. The guide documents optional native-library declarations for Android GPU access; check the app manifest against the target device when investigating missing OpenCL access. Adding declarations cannot itself increase the emulator's 128 MiB buffer limit. Do not substitute an untested SDK release into the pinned course.
Practice
Trace creation and cleanup line by line. Label the last successful phase from actual logs: file, engine, conversation, image or generation. For a compatible device, capture time-to-first-text and completion separately. Otherwise retain the error as blocked runtime evidence. Expected answer: a successful build and a responding UI establish neither a successful first token nor useful story quality.