{"record":{"id":"58d45d181f1bb485","repo":"DrKLO/Telegram","slug":"failed-to-load-decoder-native-libraries-58d45d","errorCode":null,"errorMessage":"Failed to load decoder native libraries","messagePattern":"Failed to load decoder native libraries","errorType":"exception","errorClass":"OpusDecoderException","httpStatus":null,"severity":"critical","filePath":"TMessagesProj/src/main/java/com/google/android/exoplayer2/ext/opus/OpusDecoder.java","lineNumber":85,"sourceCode":"   * @param initializationData Codec-specific initialization data. The first element must contain an\n   *     opus header. Optionally, the list may contain two additional buffers, which must contain\n   *     the encoder delay and seek pre roll values in nanoseconds, encoded as longs.\n   * @param cryptoConfig The {@link CryptoConfig} object required for decoding encrypted content.\n   *     May be null and can be ignored if decoder does not handle encrypted content.\n   * @param outputFloat Forces the decoder to output float PCM samples when set\n   * @throws OpusDecoderException Thrown if an exception occurs when initializing the decoder.\n   */\n  public OpusDecoder(\n      int numInputBuffers,\n      int numOutputBuffers,\n      int initialInputBufferSize,\n      List<byte[]> initializationData,\n      @Nullable CryptoConfig cryptoConfig,\n      boolean outputFloat)\n      throws OpusDecoderException {\n    super(new DecoderInputBuffer[numInputBuffers], new SimpleDecoderOutputBuffer[numOutputBuffers]);\n    if (!OpusLibrary.isAvailable()) {\n      throw new OpusDecoderException(\"Failed to load decoder native libraries\");\n    }\n    this.cryptoConfig = cryptoConfig;\n    if (cryptoConfig != null && !OpusLibrary.opusIsSecureDecodeSupported()) {\n      throw new OpusDecoderException(\"Opus decoder does not support secure decode\");\n    }\n    int initializationDataSize = initializationData.size();\n    if (initializationDataSize != 1 && initializationDataSize != 3) {\n      throw new OpusDecoderException(\"Invalid initialization data size\");\n    }\n    if (initializationDataSize == 3\n        && (initializationData.get(1).length != 8 || initializationData.get(2).length != 8)) {\n      throw new OpusDecoderException(\"Invalid pre-skip or seek pre-roll\");\n    }\n    preSkipSamples = getPreSkipSamples(initializationData);\n    seekPreRollSamples = getSeekPreRollSamples(initializationData);\n    skipSamples = preSkipSamples;\n\n    byte[] headerBytes = initializationData.get(0);","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/src/main/java/com/google/android/exoplayer2/ext/opus/OpusDecoder.java#L67-L103","documentation":"OpusDecoder's constructor throws OpusDecoderException('Failed to load decoder native libraries') when OpusLibrary.isAvailable() is false — the Opus extension native (.so) libraries are not packaged/loadable. It is the first check in the constructor, before any secure-decode or initialization-data validation, so the decoder cannot start without the native libs.","triggerScenarios":"Constructing OpusDecoder (via the Opus renderer) on an APK/device where the Opus native libraries are absent or not packaged for the current ABI.","commonSituations":"Opus extension not included in the build; abiFilters omitting the device ABI; release packaging stripping the .so files; running on an emulator whose ABI has no matching lib.","solutions":["Package the Opus extension native libraries for all target ABIs.","Guard on OpusLibrary.isAvailable() before enabling the Opus extension renderer; fall back to a platform Opus decoder if present.","Verify abiFilters and packagingOptions preserve the Opus .so files."],"exampleFix":"// before\nif (OpusLibrary.isAvailable()) { /* never reached */ }\n\n// after\nandroid {\n  defaultConfig { ndk { abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64' } }\n}","handlingStrategy":"validation","validationCode":"// guard on Opus library availability before enabling the Opus renderer\nif (OpusLibrary.isAvailable()) {\n  renderers.add(new OpusRenderer(...));\n} else { /* rely on a platform Opus decoder if present */ }","typeGuard":null,"tryCatchPattern":"try { new OpusDecoder(nIn, nOut, bufSize, init, crypto, outputFloat); }\ncatch (OpusDecoderException e) { /* fall back to platform Opus decoder */ }","preventionTips":["Package the Opus extension native libs for all target ABIs.","Check OpusLibrary.isAvailable() before selecting the Opus renderer.","Verify abiFilters and packaging preserve the .so files."],"tags":["audio","exoplayer","opus","native-library","jni","build"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}