Reputation: 265
I have using glide 4.6.1 to load image into the image view but it fails. Previously I was using Glide 3.6.0 to load the image in the imageview. The glide version 3.6.0 works fine and load the image perfectly from URL. To make it work from Glide 3.6.0, I followed this article android:load svg file from web and show it on image view. However, glide 4.6.1 is not loading SVG image in the image view and giving exception.
My code is :
requestBuilder = GlideApp.with(context)
.as(PictureDrawable.class)
.listener(new SvgSoftwareLayerSetter());
requestBuilder.load(uri).into(imageview);
THe officical Glide Github also shows this example I am also following that article https://github.com/bumptech/glide/tree/master/samples/svg/src/main/java/com/bumptech/glide/samples/svg.
The exception I am getting is:
com.bumptech.glide.load.engine.GlideException: Failed to load resource
There was 1 cause:
java.lang.IllegalStateException(Failed to find any load path from class android.net.Uri$StringUri to class android.graphics.drawable.PictureDrawable)
call GlideException#logRootCauses(String) for more detail
Is there any way to make Glide 4.6.1 work in a similar way to Glide 3.6.0 fro loading SVG?
Upvotes: 0
Views: 2910
Reputation: 265
Yeah got the solution was missing @GlideModule from SvgModule Class. So it should be:
**@GlideModule** //was missing this
public class SvgModule extends AppGlideModule {
@Override
public void registerComponents(@NonNull Context context, @NonNull Glide glide,
@NonNull Registry registry) {
registry.register(SVG.class, PictureDrawable.class, new SvgDrawableTranscoder())
.append(InputStream.class, SVG.class, new SvgDecoder());
}
// Disable manifest parsing to avoid adding similar modules twice.
@Override
public boolean isManifestParsingEnabled() {
return false;
}
}
Upvotes: 2