DrKLO/Telegram · critical · FlacDecoderException

Failed to load decoder native libraries.

Error message

Failed to load decoder native libraries.

What it means

FlacDecoderJni's constructor throws FlacDecoderException('Failed to load decoder native libraries.') when FlacLibrary.isAvailable() is false — the FLAC extension's native (.so) libraries are not present/loadable. This is checked before flacInit(), so the native decoder context is never created.

Source

Thrown at TMessagesProj/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoderJni.java:56

    public FlacFrameDecodeException(String message, int errorCode) {
      super(message);
      this.errorCode = errorCode;
    }
  }

  private static final int TEMP_BUFFER_SIZE = 8192; // The same buffer size as libflac.

  private final long nativeDecoderContext;

  @Nullable private ByteBuffer byteBufferData;
  @Nullable private ExtractorInput extractorInput;
  @Nullable private byte[] tempBuffer;
  private boolean endOfExtractorInput;

  public FlacDecoderJni() throws FlacDecoderException {
    if (!FlacLibrary.isAvailable()) {
      throw new FlacDecoderException("Failed to load decoder native libraries.");
    }
    nativeDecoderContext = flacInit();
    if (nativeDecoderContext == 0) {
      throw new FlacDecoderException("Failed to initialize decoder");
    }
  }

  /**
   * Sets the data to be parsed.
   *
   * @param byteBufferData Source {@link ByteBuffer}.
   */
  public void setData(ByteBuffer byteBufferData) {
    this.byteBufferData = byteBufferData;
    this.extractorInput = null;
  }

  /**

View on GitHub (pinned to 45ab8f4308)

Solutions

  1. Package the FLAC extension native libraries for all target ABIs.
  2. Guard on FlacLibrary.isAvailable() before selecting the FLAC renderer; use the platform FLAC decoder otherwise.
  3. Confirm abiFilters and packagingOptions preserve the FLAC .so files.

Example fix

// before
new FlacDecoderJni(); // crashes when libs absent

// after
if (FlacLibrary.isAvailable()) { new FlacDecoderJni(); }
else { /* use MediaCodec FLAC decoder */ }
Defensive patterns

Strategy: validation

Validate before calling

// guard on FLAC library availability
if (FlacLibrary.isAvailable()) {
  jni = new FlacDecoderJni();
} else { /* use platform MediaCodec FLAC decoder */ }

Try / catch

try { new FlacDecoderJni(); }
catch (FlacDecoderException e) { /* fall back to platform FLAC decoder */ }

Prevention

When it happens

Trigger: Instantiating FlacDecoderJni (directly or via FlacDecoder) on a build/device where the FLAC native libraries are not packaged for the current ABI.

Common situations: FLAC extension not built/included in the APK; abiFilters omitting the device ABI; .so files stripped during release packaging.

Related errors


AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14). Data as JSON: /api/errors/099335cc07b0304a. Report an issue: GitHub.