DrKLO/Telegram · error · RuntimeException
Error instantiating extension
Error message
Error instantiating extension
What it means
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.
Source
Thrown at TMessagesProj/src/main/java/com/google/android/exoplayer2/extractor/DefaultExtractorsFactory.java:536
return extractorConstructor.newInstance(constructorParams);
} catch (Exception e) {
throw new IllegalStateException("Unexpected error creating extractor", e);
}
}
@Nullable
private Constructor<? extends Extractor> maybeLoadExtractorConstructor() {
synchronized (extensionLoaded) {
if (extensionLoaded.get()) {
return extractorConstructor;
}
try {
return constructorSupplier.getConstructor();
} catch (ClassNotFoundException e) {
// Expected if the app was built without the extension.
} catch (Exception e) {
// The extension is present, but instantiation failed.
throw new RuntimeException("Error instantiating extension", e);
}
extensionLoaded.set(true);
return extractorConstructor;
}
}
}
}
View on GitHub (pinned to 45ab8f4308)
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.
Defensive patterns
Strategy: try-catch
Try / catch
try {
Extractor ex = factory.getExtractor(flags);
} catch (RuntimeException e) {
if (e.getMessage().equals("Error instantiating extension")) {
Throwable cause = e.getCause();
// ClassNotFoundException is expected/swallowed; anything else means the extension is
// present but broken (missing native lib, version skew, ProGuard). Fix packaging accordingly.
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Version mismatch between extension and core (constructor signature changed); extension shipped without its native library; ProGuard/R8 stripping the constructor; multidex/dexer ordering issues.
Related errors
- Unexpected error creating extractor
- Cannot read frame at position {lastDecodePosition}
- Opus decoder does not support secure decode
- Failed to initialize decoder
- {positionDescription}: Error creating LayoutManager {classNa
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/636bbdd904653a9d.
Report an issue: GitHub.