首页 > 解决方案 > Glide 和 Picasso 无法从 YouTube 加载图像

问题描述

我是 ImageView、Picasso、Glide 的新手。我只想从 url 加载图像,我尝试过 Glide 和 Picasso。他们都可以很好地加载图像,但如果我尝试从 youtube(缩略图)加载图像 - 不加载。// http://i.ytimg.com/vi/z0NfI2NeDHI/sddefault.jpg - 不加载

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" />

日志猫

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

标签: androidimagepicassoandroid-glide

解决方案


我认为您面临的问题与 Glide、Picasso 等图书馆无关。我尝试使用您提供的图片链接Glide,它按预期工作。

我有根据的猜测是,您的设备正在使用某种受限网络,因此它会阻止来自 youtube 端点的进出请求。如果你从另一个网络连接它会工作得很好。


推荐阅读