DrKLO/Telegram · error · IllegalStateException
Unexpected error creating extractor
Error message
Unexpected error creating extractor
What it means
DefaultExtractorsFactory.ExtensionLoader.getExtractor() reflectively instantiates an extension Extractor via Constructor.newInstance(constructorParams). Any exception thrown by the extension's constructor (or by newInstance itself, e.g. wrong arg types) is wrapped and rethrown as IllegalStateException. The extension class was found; only its instantiation blew up.
Source
Thrown at TMessagesProj/src/main/java/com/google/android/exoplayer2/extractor/DefaultExtractorsFactory.java:520
@Nullable
private Constructor<? extends Extractor> extractorConstructor;
public ExtensionLoader(ConstructorSupplier constructorSupplier) {
this.constructorSupplier = constructorSupplier;
extensionLoaded = new AtomicBoolean(false);
}
@Nullable
public Extractor getExtractor(Object... constructorParams) {
@Nullable
Constructor<? extends Extractor> extractorConstructor = maybeLoadExtractorConstructor();
if (extractorConstructor == null) {
return null;
}
try {
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);View on GitHub (pinned to 45ab8f4308)
Solutions
- Inspect the wrapped cause (the IllegalStateException's cause) to find the real failure.
- Ensure the constructorParams passed to the factory match the extension Extractor's constructor signature.
- Use matching core/extension versions; rebuild the extension against the current core.
Example fix
// before - passing a param the extension ctor does not accept factory.getExtractor(SomeUnsupportedFlag.class); // after - pass the documented Extractor flag constants the ctor expects factory.getExtractor(Extractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING);
Defensive patterns
Strategy: try-catch
Validate before calling
// Verify the constructor-params match what the extension Extractor expects before asking for it.
// (e.g. FLAC/Opus extractors take an int flags arg from Extractor.FLAG_*)
if (!(constructorParams instanceof Integer)) {
// pass Extractor.FLAG_* ints only
} Try / catch
try {
Extractor ex = extensionLoader.getExtractor(constructorParams);
} catch (IllegalStateException e) {
Throwable cause = e.getCause();
// inspect cause: wrong arg types -> fix factory call; static init failure -> fix extension
} Prevention
- Pass only the documented Extractor flag constants as constructorParams.
- Keep extension and ExoPlayer core versions aligned.
- Inspect the wrapped cause of IllegalStateException before guessing.
When it happens
Trigger: Calling extractors factory methods that resolve an extension extractor (e.g. FLAC, Opus) and the resolved Extractor constructor throws - because constructorParams do not match the constructor's expected types, or the constructor does I/O/static-init that fails.
Common situations: Passing constructor flags (e.g. constant Mode flags) the extension constructor does not accept; an extension whose static initializer fails; a version skew between the ExoPlayer core and the extension.
Related errors
- Error instantiating extension
- Cannot read frame at position {lastDecodePosition}
- {positionDescription}: Error creating LayoutManager {classNa
- {positionDescription}: Unable to find LayoutManager {classNa
- {positionDescription}: Could not instantiate the LayoutManag
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/505ad790e803368d.
Report an issue: GitHub.