{"record":{"id":"636bbdd904653a9d","repo":"DrKLO/Telegram","slug":"error-instantiating-extension","errorCode":null,"errorMessage":"Error instantiating extension","messagePattern":"Error instantiating extension","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"TMessagesProj/src/main/java/com/google/android/exoplayer2/extractor/DefaultExtractorsFactory.java","lineNumber":536,"sourceCode":"        return extractorConstructor.newInstance(constructorParams);\n      } catch (Exception e) {\n        throw new IllegalStateException(\"Unexpected error creating extractor\", e);\n      }\n    }\n\n    @Nullable\n    private Constructor<? extends Extractor> maybeLoadExtractorConstructor() {\n      synchronized (extensionLoaded) {\n        if (extensionLoaded.get()) {\n          return extractorConstructor;\n        }\n        try {\n          return constructorSupplier.getConstructor();\n        } catch (ClassNotFoundException e) {\n          // Expected if the app was built without the extension.\n        } catch (Exception e) {\n          // The extension is present, but instantiation failed.\n          throw new RuntimeException(\"Error instantiating extension\", e);\n        }\n        extensionLoaded.set(true);\n        return extractorConstructor;\n      }\n    }\n  }\n}\n","sourceCodeStart":518,"sourceCodeEnd":544,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/src/main/java/com/google/android/exoplayer2/extractor/DefaultExtractorsFactory.java#L518-L544","documentation":"ExtensionLoader.maybeLoadExtractorConstructor() calls the ConstructorSupplier to look up the extension's Constructor. ClassNotFoundException is expected and swallowed (app built without the extension), but any other exception - NoSuchMethodException, InvocationTargetException, IllegalAccessException - is wrapped in RuntimeException('Error instantiating extension'). It means the extension class is on the classpath but its constructor could not be resolved or its loading failed.","triggerScenarios":"An extension (e.g. com.google.android.exoplayer2.ext.flac.FlacExtractor) is present but its expected constructor is missing, its static initializer threw, or it could not be linked - e.g. its own native dependency (libflac) is missing at class-load time.","commonSituations":"Version mismatch between extension and core (constructor signature changed); extension shipped without its native library; ProGuard/R8 stripping the constructor; multidex/dexer ordering issues.","solutions":["Inspect the RuntimeException's cause for the exact linkage/init failure.","Ship the extension's native library alongside its Java classes (e.g. libflac JNI).","Use a core/extension pair from the same release; keep ProGuard rules that keep Extractor constructors."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  Extractor ex = factory.getExtractor(flags);\n} catch (RuntimeException e) {\n  if (e.getMessage().equals(\"Error instantiating extension\")) {\n    Throwable cause = e.getCause();\n    // ClassNotFoundException is expected/swallowed; anything else means the extension is\n    // present but broken (missing native lib, version skew, ProGuard). Fix packaging accordingly.\n  }\n}","preventionTips":["Ship each extension's native library alongside its Java classes.","Use matching core/extension release versions.","Keep ProGuard/R8 rules that retain Extractor constructors and extension classes."],"tags":["exoplayer","extractor","reflection","classloading","native"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}