bumptech/glide · error · NoSourceEncoderAvailableException

Failed to find source encoder for data class: {dataClass}

Error message

Failed to find source encoder for data class: {dataClass}

What it means

Thrown (as NoSourceEncoderAvailableException) by Registry.getSourceEncoder() when no Encoder is registered for the given data's class. Glide needs a source encoder to write the original/decoded data (before transformation) to the disk cache; without one it cannot cache that data type.

Source

Thrown at library/src/main/java/com/bumptech/glide/Registry.java:585

  @NonNull
  public <X> ResourceEncoder<X> getResultEncoder(@NonNull Resource<X> resource)
      throws NoResultEncoderAvailableException {
    ResourceEncoder<X> resourceEncoder = resourceEncoderRegistry.get(resource.getResourceClass());
    if (resourceEncoder != null) {
      return resourceEncoder;
    }
    throw new NoResultEncoderAvailableException(resource.getResourceClass());
  }

  @NonNull
  @SuppressWarnings("unchecked")
  public <X> Encoder<X> getSourceEncoder(@NonNull X data) throws NoSourceEncoderAvailableException {
    Encoder<X> encoder = encoderRegistry.getEncoder((Class<X>) data.getClass());
    if (encoder != null) {
      return encoder;
    }
    throw new NoSourceEncoderAvailableException(data.getClass());
  }

  @NonNull
  public <X> DataRewinder<X> getRewinder(@NonNull X data) {
    return dataRewinderRegistry.build(data);
  }

  @NonNull
  public <Model> List<ModelLoader<Model, ?>> getModelLoaders(@NonNull Model model) {
    return modelLoaderRegistry.getModelLoaders(model);
  }

  @NonNull
  public List<ImageHeaderParser> getImageHeaderParsers() {
    List<ImageHeaderParser> result = imageHeaderParserRegistry.getParsers();
    if (result.isEmpty()) {
      throw new NoImageHeaderParserException();
    }

View on GitHub (pinned to eb14a895d8)

Solutions

  1. Register an Encoder for your data class in Registry via registry.append(...).
  2. Switch to DiskCacheStrategy.NONE (or RESOURCE if a result encoder exists) to avoid requiring a source encoder.
  3. Ensure the data type returned by your ModelLoader/DataFetcher has a matching Encoder registration.
  4. Verify you append both a ModelLoader/decoder and an Encoder for any fully new data type.

Example fix

// before
// custom data type 'MyData' has no source encoder -> NoSourceEncoderAvailableException
Glide.with(view).load(model).diskCacheStrategy(DiskCacheStrategy.DATA).into(view)

// after (option A)
registry.append(MyData::class.java, MyDataEncoder())
// after (option B)
Glide.with(view).load(model).diskCacheStrategy(DiskCacheStrategy.NONE).into(view)
Defensive patterns

Strategy: try-catch

Validate before calling

// If you cache source data, ensure an Encoder exists for its type.
// Option: register an Encoder for MyData in Registry, or avoid DiskCacheStrategy.DATA.
Glide.with(view)
  .load(model)
  .diskCacheStrategy(DiskCacheStrategy.NONE) // when no source encoder is registered
  .into(view)

Try / catch

try {
  glide.registry.getSourceEncoder(data)
} catch (e: NoSourceEncoderAvailableException) {
  // register Encoder<MyData> or use DiskCacheStrategy.NONE
}

Prevention

When it happens

Trigger: getSourceEncoder(data) looks up encoderRegistry.getEncoder(data.getClass()); if null, NoSourceEncoderAvailableException is thrown with the data class name.

Common situations: Using DiskCacheStrategy.DATA/ALL with a custom data source type for which no Encoder is registered; a custom ModelLoader producing an unusual data type; loading from a model whose decoded data type lacks an encoder.

Related errors


AI-assisted analysis of bumptech/glide@eb14a895d8 (2026-08-14). Data as JSON: /api/errors/30e29f6e43564ad2. Report an issue: GitHub.