{"record":{"id":"85c4c41f5186fbca","repo":"google/ExoPlayer","slug":"failed-to-load-decoder-native-libraries-85c4c4","errorCode":null,"errorMessage":"Failed to load decoder native libraries.","messagePattern":"Failed to load decoder native libraries\\.","errorType":"exception","errorClass":"VpxDecoderException","httpStatus":null,"severity":"error","filePath":"extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxDecoder.java","lineNumber":80,"sourceCode":"   *\n   * @param numInputBuffers The number of input buffers.\n   * @param numOutputBuffers The number of output buffers.\n   * @param initialInputBufferSize The initial size of each input buffer.\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 threads Number of threads libvpx will use to decode.\n   * @throws VpxDecoderException Thrown if an exception occurs when initializing the decoder.\n   */\n  public VpxDecoder(\n      int numInputBuffers,\n      int numOutputBuffers,\n      int initialInputBufferSize,\n      @Nullable CryptoConfig cryptoConfig,\n      int threads)\n      throws VpxDecoderException {\n    super(new DecoderInputBuffer[numInputBuffers], new VideoDecoderOutputBuffer[numOutputBuffers]);\n    if (!VpxLibrary.isAvailable()) {\n      throw new VpxDecoderException(\"Failed to load decoder native libraries.\");\n    }\n    this.cryptoConfig = cryptoConfig;\n    if (cryptoConfig != null && !VpxLibrary.vpxIsSecureDecodeSupported()) {\n      throw new VpxDecoderException(\"Vpx decoder does not support secure decode.\");\n    }\n    vpxDecContext =\n        vpxInit(/* disableLoopFilter= */ false, /* enableRowMultiThreadMode= */ false, threads);\n    if (vpxDecContext == 0) {\n      throw new VpxDecoderException(\"Failed to initialize decoder\");\n    }\n    setInitialInputBufferSize(initialInputBufferSize);\n  }\n\n  @Override\n  public String getName() {\n    return \"libvpx\" + VpxLibrary.getVersion();\n  }\n","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/google/ExoPlayer/blob/dd430f7053a1a3958deea3ead6a0565150c06bfc/extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxDecoder.java#L62-L98","documentation":"VpxDecoder's constructor checks VpxLibrary.isAvailable() and throws if the libvpx native libraries (libvpx + the JNI wrapper) could not be loaded. This is a deployment/packaging failure: the APK does not contain the expected .so files for the device ABI, so no VP9 software decoding is possible.","triggerScenarios":"Instantiating VpxDecoder (e.g. LibvpxVideoRenderer being used for a VP9 track) on a device whose ABI has no matching libvpx JNI library, or where System.loadLibrary failed earlier. VpxLibrary.isAvailable() returns false.","commonSituations":"Forgetting to add the extension's AAR/JNI dependency or only shipping armv7 libs to an arm64-only device; proguard/R8 stripping the JNI wrapper; using the renderer on emulators with uncommon ABIs; missing ReLinker flags in custom builds.","solutions":["Ensure the VP9 extension (and its native libs for all supported ABIs: armeabi-v7a, arm64-v8a, x86, x86_64) is packaged — check the APK's lib/ directories.","Call VpxLibrary.isAvailable() before playback and, if false, fall back to MediaCodec VP9 decoding or exclude the extension renderer via DefaultRenderersFactory.","If building the extension from source, verify the NDK build produced and loaded libvpx + JNI wrapper correctly.","Keep the extension .so files out of ABI splits that omit them, or restrict abiFilters accordingly."],"exampleFix":"// before\nDefaultRenderersFactory factory = new DefaultRenderersFactory(context); // includes libvpx renderer\n\n// after\nDefaultRenderersFactory factory = new DefaultRenderersFactory(context);\nif (!VpxLibrary.isAvailable()) {\n  factory.setAllowedVideoDecoders(Arrays.asList(\"OMX.google.vp9.decoder\"));\n  // or build the factory with setEnableDecoderFallback(true) and let MediaCodec handle VP9\n}","handlingStrategy":"fallback","validationCode":"if (!VpxLibrary.isAvailable()) { /* build RenderersFactory without LibvpxVideoRenderer; rely on MediaCodec VP9 */ }","typeGuard":null,"tryCatchPattern":"catch (VpxDecoderException e) during renderer selection -> skip the libvpx renderer and let MediaCodec try the track.","preventionTips":["Check VpxLibrary.isAvailable() at startup and choose the renderer list accordingly.","Ship native libs for every ABI you support (or restrict abiFilters).","Verify the APK's lib/ folders contain libvpx and the JNI wrapper in CI."],"tags":["vp9","native-library","packaging","abi","exoplayer-extension"],"backgroundTag":null,"analyzedSha":"dd430f7053a1a3958deea3ead6a0565150c06bfc","analyzedAt":"2026-08-14T12:22:02.982Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}