{"record":{"id":"099335cc07b0304a","repo":"DrKLO/Telegram","slug":"failed-to-load-decoder-native-libraries-099335","errorCode":null,"errorMessage":"Failed to load decoder native libraries.","messagePattern":"Failed to load decoder native libraries\\.","errorType":"exception","errorClass":"FlacDecoderException","httpStatus":null,"severity":"critical","filePath":"TMessagesProj/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoderJni.java","lineNumber":56,"sourceCode":"\n    public FlacFrameDecodeException(String message, int errorCode) {\n      super(message);\n      this.errorCode = errorCode;\n    }\n  }\n\n  private static final int TEMP_BUFFER_SIZE = 8192; // The same buffer size as libflac.\n\n  private final long nativeDecoderContext;\n\n  @Nullable private ByteBuffer byteBufferData;\n  @Nullable private ExtractorInput extractorInput;\n  @Nullable private byte[] tempBuffer;\n  private boolean endOfExtractorInput;\n\n  public FlacDecoderJni() throws FlacDecoderException {\n    if (!FlacLibrary.isAvailable()) {\n      throw new FlacDecoderException(\"Failed to load decoder native libraries.\");\n    }\n    nativeDecoderContext = flacInit();\n    if (nativeDecoderContext == 0) {\n      throw new FlacDecoderException(\"Failed to initialize decoder\");\n    }\n  }\n\n  /**\n   * Sets the data to be parsed.\n   *\n   * @param byteBufferData Source {@link ByteBuffer}.\n   */\n  public void setData(ByteBuffer byteBufferData) {\n    this.byteBufferData = byteBufferData;\n    this.extractorInput = null;\n  }\n\n  /**","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoderJni.java#L38-L74","documentation":"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.","triggerScenarios":"Instantiating FlacDecoderJni (directly or via FlacDecoder) on a build/device where the FLAC native libraries are not packaged for the current ABI.","commonSituations":"FLAC extension not built/included in the APK; abiFilters omitting the device ABI; .so files stripped during release packaging.","solutions":["Package the FLAC extension native libraries for all target ABIs.","Guard on FlacLibrary.isAvailable() before selecting the FLAC renderer; use the platform FLAC decoder otherwise.","Confirm abiFilters and packagingOptions preserve the FLAC .so files."],"exampleFix":"// before\nnew FlacDecoderJni(); // crashes when libs absent\n\n// after\nif (FlacLibrary.isAvailable()) { new FlacDecoderJni(); }\nelse { /* use MediaCodec FLAC decoder */ }","handlingStrategy":"validation","validationCode":"// guard on FLAC library availability\nif (FlacLibrary.isAvailable()) {\n  jni = new FlacDecoderJni();\n} else { /* use platform MediaCodec FLAC decoder */ }","typeGuard":null,"tryCatchPattern":"try { new FlacDecoderJni(); }\ncatch (FlacDecoderException e) { /* fall back to platform FLAC decoder */ }","preventionTips":["Package the FLAC extension native libs for all target ABIs.","Check FlacLibrary.isAvailable() before selecting the FLAC renderer.","Verify abiFilters and packaging preserve the .so files."],"tags":["audio","exoplayer","flac","native-library","jni","build"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}