0

I'm new with ImageView, Picasso, Glide. I want just to load image from url, i've tried Glide and Picasso. Both of them load images well but if i try to load images from youtube(thumbnail) - not loading. // http://i.ytimg.com/vi/z0NfI2NeDHI/sddefault.jpg - not loading

MainActivity.java

imageView = findViewById(R.id.image);
videoImg = ""
fetchData.execute(); //returns link for image to videoImg
Glide.with(this)
                .load(videoImg)
                .placeholder(R.drawable.ic_launcher_background)
                .error(R.drawable.ic_launcher_foreground)
                .into(imageView);
        Picasso.get().load(videoImg).into(imageView);

activity_main.xml

<ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

LogCat

W/Glide: Failed to find GeneratedAppGlideModule. You should include an annotationProcessor compile dependency on com.github.bumptech.glide:compiler in your application and a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored
W/Glide: Load failed for null with size [0x0]
    class com.bumptech.glide.load.engine.GlideException: Received null model
Max Dev
  • 189
  • 1
  • 1
  • 12

3 Answers3

1

I think the problem you're facing is nothing related to the libraries like Glide, Picasso or others. I tried with the image link you provided using Glide and it works as expected.

My educated guess is that your device is using some kind of restricted network so it blocks the requests in/out from youtube endpoints. If you connect from another network it would work just fine.

Gunhan
  • 6,807
  • 3
  • 43
  • 37
  • Thank you for answer! I've tried to connect from another network, but it did not helped.. – Max Dev Apr 30 '19 at 19:11
  • @MaxDev Could you try going to the web browser on the device and copy paste the link and see if you can access it? – Gunhan May 01 '19 at 10:02
0

If you just want to load the image into the ImageView just stick with one Library, let's say Glide.

  1. First of all by looking at your code, you should declare videoImg like this:

    videoImg = "http://i.ytimg.com/vi/z0NfI2NeDHI/sddefault.jpg";

  2. Then check your dependencies, you should add the correct one as followed:

    implementation 'com.github.bumptech.glide:glide:4.9.0'

    annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'

Don't forget to add mavenCentral() to repositeries in your project file under builscript

  1. add Internet permission in your manifest:

    <uses-permission android:name="android.permission.INTERNET"/>

Shid
  • 1,336
  • 1
  • 15
  • 18
0

Well, awkward situation.. I use custom AsyncTask which returns String(link to yt image)(in my case videoImg) so my code was:

void ShowImage(View v){
    fetchData.execute();
    Glide.with(MainActivity.this)
                .load(videoImg)
                .placeholder(R.drawable.ic_launcher_background)
                .error(R.drawable.ic_launcher_foreground)
                .into(imageView);
}

So AsyncTask does not have time to download the link and Glide just trying to load empty string..

Sorry again..

Max Dev
  • 189
  • 1
  • 1
  • 12