老师,Glide加载图片的问题

来源:3-2 选择题

魈小混球

2018-07-12 18:10:20

 @OnClick(R.id.button)
   public void onViewClicked() {
       String pic_url = "https://www.baidu.com/img/bd_logo1.png";
//        Glide.with(this).load(pic_url).into(imageView);
       Picasso.get().load(pic_url).into(imageView);
   }




W/Glide: Load failed for https://www.baidu.com/img/bd_logo1.png with size [96x96]

         class com.bumptech.glide.load.engine.GlideException: Failed to load resource

         There were 2 causes:

         java.net.UnknownHostException(Unable to resolve host "www.baidu.com": No address associated with hostname)

         java.io.FileNotFoundException(No content provider: https://www.baidu.com/img/bd_logo1.png)

          call GlideException#logRootCauses(String) for more detail

           Cause (1 of 2): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, REMOTE

         There was 1 cause:

         java.net.UnknownHostException(Unable to resolve host "www.baidu.com": No address associated with hostname)

          call GlideException#logRootCauses(String) for more detail

             Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed

         There was 1 cause:

         java.net.UnknownHostException(Unable to resolve host "www.baidu.com": No address associated with hostname)

          call GlideException#logRootCauses(String) for more detail

               Cause (1 of 1): class java.net.UnknownHostException: Unable to resolve host "www.baidu.com": No address associated with hostname

           Cause (2 of 2): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class android.content.res.AssetFileDescriptor, LOCAL

         There was 1 cause:

         java.io.FileNotFoundException(No content provider: https://www.baidu.com/img/bd_logo1.png)

          call GlideException#logRootCauses(String) for more detail

             Cause (1 of 1): class java.io.FileNotFoundException: No content provider: https://www.baidu.com/img/bd_logo1.png


写回答

1回答

irista23

2018-07-12

Glide操作你这两行代码是没有问题的,检查一下添加的依赖有没有问题

比如:'com.github.bumptech.glide:glide:3.7.0',另外清单文件中的网络访问权限是否添加正确

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

http://img.mukewang.com/climg/5b472d1e00017a5805070079.jpg

0

0 学习 · 687 问题

查看课程