Skip to content

fix(sherpa-native): Android build fails — HappierSherpaNativeJni.cpp missing #include <vector> (NDK 27 libc++) #201

Description

@danljungstrom

Summary

The nightly Android APK build has failed every run since ~2026-06-21. The UI mobile (dev) / publish job in NIGHTLY — Dev Releases dies at the native C++ compile step, so no new happier-dev-android.apk has shipped in ~3.5 weeks (last successful asset: ui-mobile-dev @ 2026-06-21, version 0.2.7). All other components (server/cli/hstack/ui-web/desktop/docker) publish fine, so the overall nightly run is marked failed but the breakage is mobile-only.

Error

packages/sherpa-native/android/src/main/cpp/HappierSherpaNativeJni.cpp:202:24:
  error: implicit instantiation of undefined template 'std::vector<float>'
  note: template is declared here  (…/c++/v1/iosfwd:168)
HappierSherpaNativeJni.cpp:210 / :393  — same for std::vector<float> / std::vector<int16_t>
5 errors generated.
ninja: build stopped: subcommand failed.
C++ build system [build] failed … happier_sherpa_jni … arm64-v8a
BUILD FAILED
> npx [email protected] build --platform android --profile publicdev-apk --local … exit 1

Toolchain: ndk/27.0.12077973, cmake 3.22.1, EAS local build via Dagger.

Root cause

HappierSherpaNativeJni.cpp uses std::vector<float> and std::vector<int16_t> but never includes <vector> (nor <cstdint> for int16_t). Current includes: <jni.h> <atomic> <mutex> <string> <unordered_map> <memory> + sherpa-onnx/c-api.h. It was relying on <vector> being pulled in transitively. NDK 27's libc++ tightened its headers (only a forward decl from <iosfwd> is now visible), so the transitive include vanished.

Latent bug, not a code change: the file has a single commit (bc1d1819, 2026-02-15, never modified). The break coincides with the CI build image / NDK bump to 27 — nothing in the app repo changed.

Fix

Add the missing includes to HappierSherpaNativeJni.cpp:

#include <vector>
#include <cstdint>

Follow-ups worth considering

  • Grep other native modules (audio-stream-native, etc.) for the same latent transitive-include reliance under NDK 27.
  • Make the UI mobile (dev) / publish failure page/alert — it silently failed for 3.5 weeks because the other components kept publishing and masked the red run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions