How to load Vector Drawable resources from the web using libs like Glide/Picasso?

1

What I'm trying to do

Suppose that I have a Vector Drawable XML file hosted somewhere on the web. I want to display that image resource in my app using either Glide or Picasso, would that be possible?

What have I tried so far

I've seen this question and it seems to be possible to do it "manually". I also know that it's possible to load rasterized images. But I wonder if there's a way to do it like:

Glide.with(activity)
    .load(vectorDrawableUrl)
    .into(imageView)

Or even:

Picasso.get()
    .load(vectorDrawableUrl)
    .into(imageView)

From my initial tests, it didn't work. Glide started to pop some random errors, like:

W/Glide: Load failed for https://path.to.url/ic_key.xml with size [420x420]
    class com.bumptech.glide.load.engine.GlideException: Failed to load resource
    There were 8 causes:
    java.io.IOException(java.lang.RuntimeException: setDataSourceCallback failed: status = 0x80000000)
    java.io.IOException(java.lang.RuntimeException: setDataSourceCallback failed: status = 0x80000000)
    java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
    java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
    java.io.IOException(java.lang.RuntimeException: setDataSourceCallback failed: status = 0x80000000)
    java.io.IOException(java.lang.RuntimeException: setDataSourceCallback failed: status = 0x80000000)
    java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
    java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)

And with Picasso I got:

D/skia: --- Failed to create image decoder with message 'unimplemented'
D/skia: --- Failed to create image decoder with message 'unimplemented'
D/skia: --- Failed to create image decoder with message 'unimplemented'

Am I missing something?

Update

It seems that those vector drawables are transformed with AAPT, and that might make things more difficult (or even impossible). Perhaps that's why I was unable to load the files directly.

android
picasso
android-glide
android-vectordrawable
aapt
asked on Stack Overflow Oct 27, 2020 by Mauker • edited Oct 29, 2020 by Mauker

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0