原因(1 / 1):class com.bumptech.glide.load.engine.GlideException:获取数据失败

huangapple 未分类评论56阅读模式
英文:

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

问题

  1. 我正在尝试使用Glide加载个人资料图片,但在运行时抛出了空URL的错误。以下是代码部分:
  2. BindingAdapters.java
  3. public final class BindingAdapters {
  4. @BindingAdapter({"app:profile_url"})
  5. public static void loadProfileImage(ImageView view, String profileUrl) {
  6. new GlideLoader(view.getContext()).loadWithCircleCrop("http://aplikasi.muanetoraya.com/jaih/uploads/" + profileUrl, view);
  7. }
  8. @BindingAdapter({"app:image_url"})
  9. public static void loadImage(ImageView view, String profileUrl) {
  10. String url = "http://aplikasi.muanetoraya.com/jaih/uploads/" + profileUrl;
  11. new GlideLoader(view.getContext()).loadImage(url, view);
  12. }
  13. }

这段代码在运行时抛出以下错误:

  1. W/Glide: 加载失败,大小为 [240x240],URLhttp://aplikasi.muanetoraya.com/jaih/uploads/null
  2. class com.bumptech.glide.load.engine.GlideException: 无法加载资源
  3. 原因如下:
  4. java.io.FileNotFoundException(http://aplikasi.muanetoraya.com/jaih/uploads/null)
  5. 请调用 GlideException#logRootCauses(String) 以获取更多详细信息
  6. 原因 (1 of 1): class com.bumptech.glide.load.engine.GlideException: 获取数据失败,类为 java.io.InputStream,远程
  7. 原因如下:
  8. java.io.FileNotFoundException(http://aplikasi.muanetoraya.com/jaih/uploads/null)
  9. 请调用 GlideException#logRootCauses(String) 以获取更多详细信息
  10. 原因 (1 of 1): class com.bumptech.glide.load.engine.GlideException: 获取失败
  11. 原因如下:
  12. java.io.FileNotFoundException(http://aplikasi.muanetoraya.com/jaih/uploads/null)
  13. 请调用 GlideException#logRootCauses(String) 以获取更多详细信息
  14. 原因 (1 of 1): class java.io.FileNotFoundException: http://aplikasi.muanetoraya.com/jaih/uploads/null
  15. I/Glide: 根本原因 (1 of 1)
  16. java.io.FileNotFoundException: http://aplikasi.muanetoraya.com/jaih/uploads/null
  17. at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:255)
  18. at com.bumptech.glide.load.data.HttpUrlFetcher.loadDataWithRedirects(HttpUrlFetcher.java:102)
  19. at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:56)
  20. ...
  1. <details>
  2. <summary>英文:</summary>
  3. Im trying to load profile image with Glide but when I run it throw a null url

W/Glide: Load failed for
http://aplikasi.muanetoraya.com/jaih/uploads/null with size [240x240]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
There was 1 cause:
java.io.FileNotFoundException(http://aplikasi.muanetoraya.com/jaih/uploads/null)
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetching data failed,
class java.io.InputStream, REMOTE
There was 1 cause:
java.io.FileNotFoundException(http://aplikasi.muanetoraya.com/jaih/uploads/null)
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.io.FileNotFoundException(http://aplikasi.muanetoraya.com/jaih/uploads/null)
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class java.io.FileNotFoundException: http://aplikasi.muanetoraya.com/jaih/uploads/null I/Glide: Root cause (1 of 1)
java.io.FileNotFoundException: http://aplikasi.muanetoraya.com/jaih/uploads/null

  1. Here is my code:
  2. BindingAdapters.java
  3. public final class BindingAdapters {
  4. @BindingAdapter({&quot;app:profile_url&quot;})
  5. public static void loadProfileImage(ImageView view, String profileUrl) {
  6. new GlideLoader(view.getContext()).loadWithCircleCrop(&quot;http://aplikasi.muanetoraya.com/jaih/uploads/&quot; + profileUrl, view);
  7. }
  8. @BindingAdapter({&quot;app:image_url&quot;})
  9. public static void loadImage(ImageView view, String profileUrl) {
  10. String url = &quot;http://aplikasi.muanetoraya.com/jaih/uploads/&quot; + profileUrl;
  11. new GlideLoader(view.getContext()).loadImage(url, view);
  12. }
  13. and it throw error like this:
  14. W/Glide: Load failed for http://aplikasi.muanetoraya.com/jaih/uploads/null with size [240x240]
  15. class com.bumptech.glide.load.engine.GlideException: Failed to load resource
  16. There was 1 cause:
  17. java.io.FileNotFoundException(http://aplikasi.muanetoraya.com/jaih/uploads/null)
  18. call GlideException#logRootCauses(String) for more detail
  19. Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, REMOTE
  20. There was 1 cause:
  21. java.io.FileNotFoundException(http://aplikasi.muanetoraya.com/jaih/uploads/null)
  22. call GlideException#logRootCauses(String) for more detail
  23. Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed
  24. There was 1 cause:
  25. java.io.FileNotFoundException(http://aplikasi.muanetoraya.com/jaih/uploads/null)
  26. call GlideException#logRootCauses(String) for more detail
  27. Cause (1 of 1): class java.io.FileNotFoundException: http://aplikasi.muanetoraya.com/jaih/uploads/null
  28. I/Glide: Root cause (1 of 1)
  29. java.io.FileNotFoundException: http://aplikasi.muanetoraya.com/jaih/uploads/null
  30. at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:255)
  31. at com.bumptech.glide.load.data.HttpUrlFetcher.loadDataWithRedirects(HttpUrlFetcher.java:102)
  32. at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:56)
  33. at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
  34. at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:164)
  35. at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:154)
  36. at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:62)
  37. at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
  38. at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:70)
  39. at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:63)
  40. at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:310)
  41. at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:279)
  42. at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:234)
  43. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
  44. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
  45. at java.lang.Thread.run(Thread.java:919)
  46. at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:393)
  47. </details>
  48. # 答案1
  49. **得分**: 2

java.io.FileNotFoundException(http://aplikasi.muanetoraya.com/jaih/uploads/null)
表示您的
profileUrl
为空,因此此链接http://aplikasi.muanetoraya.com/jaih/uploads/null中的资源可能不可用。

  1. <details>
  2. <summary>英文:</summary>
  3. &gt; java.io.FileNotFoundException(http://aplikasi.muanetoraya.com/jaih/uploads/null)
  4. means your
  5. &gt; profileUrl
  6. is null and therefore the resource i this http://aplikasi.muanetoraya.com/jaih/uploads/null link is probably not available
  7. </details>

huangapple
  • 本文由 发表于 2020年7月28日 22:23:52
  • 转载请务必保留本文链接:https://java.coder-hub.com/63136372.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定