英文:
Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetching data failed
问题
我正在尝试使用Glide加载个人资料图片,但在运行时抛出了空URL的错误。以下是代码部分:
BindingAdapters.java
public final class BindingAdapters {
@BindingAdapter({"app:profile_url"})
public static void loadProfileImage(ImageView view, String profileUrl) {
new GlideLoader(view.getContext()).loadWithCircleCrop("http://aplikasi.muanetoraya.com/jaih/uploads/" + profileUrl, view);
}
@BindingAdapter({"app:image_url"})
public static void loadImage(ImageView view, String profileUrl) {
String url = "http://aplikasi.muanetoraya.com/jaih/uploads/" + profileUrl;
new GlideLoader(view.getContext()).loadImage(url, view);
}
}
这段代码在运行时抛出以下错误:
W/Glide: 加载失败,大小为 [240x240],URL:http://aplikasi.muanetoraya.com/jaih/uploads/null
class com.bumptech.glide.load.engine.GlideException: 无法加载资源
原因如下:
java.io.FileNotFoundException(http://aplikasi.muanetoraya.com/jaih/uploads/null)
请调用 GlideException#logRootCauses(String) 以获取更多详细信息
原因 (1 of 1): class com.bumptech.glide.load.engine.GlideException: 获取数据失败,类为 java.io.InputStream,远程
原因如下:
java.io.FileNotFoundException(http://aplikasi.muanetoraya.com/jaih/uploads/null)
请调用 GlideException#logRootCauses(String) 以获取更多详细信息
原因 (1 of 1): class com.bumptech.glide.load.engine.GlideException: 获取失败
原因如下:
java.io.FileNotFoundException(http://aplikasi.muanetoraya.com/jaih/uploads/null)
请调用 GlideException#logRootCauses(String) 以获取更多详细信息
原因 (1 of 1): class java.io.FileNotFoundException: http://aplikasi.muanetoraya.com/jaih/uploads/null
I/Glide: 根本原因 (1 of 1)
java.io.FileNotFoundException: http://aplikasi.muanetoraya.com/jaih/uploads/null
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:255)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadDataWithRedirects(HttpUrlFetcher.java:102)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:56)
...
<details>
<summary>英文:</summary>
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
Here is my code:
BindingAdapters.java
public final class BindingAdapters {
@BindingAdapter({"app:profile_url"})
public static void loadProfileImage(ImageView view, String profileUrl) {
new GlideLoader(view.getContext()).loadWithCircleCrop("http://aplikasi.muanetoraya.com/jaih/uploads/" + profileUrl, view);
}
@BindingAdapter({"app:image_url"})
public static void loadImage(ImageView view, String profileUrl) {
String url = "http://aplikasi.muanetoraya.com/jaih/uploads/" + profileUrl;
new GlideLoader(view.getContext()).loadImage(url, view);
}
and it throw error like this:
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
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:255)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadDataWithRedirects(HttpUrlFetcher.java:102)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:56)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:164)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:154)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:62)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:70)
at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:63)
at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:310)
at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:279)
at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:393)
</details>
# 答案1
**得分**: 2
java.io.FileNotFoundException(http://aplikasi.muanetoraya.com/jaih/uploads/null)
表示您的
profileUrl
为空,因此此链接http://aplikasi.muanetoraya.com/jaih/uploads/null中的资源可能不可用。
<details>
<summary>英文:</summary>
> java.io.FileNotFoundException(http://aplikasi.muanetoraya.com/jaih/uploads/null)
means your
> profileUrl
is null and therefore the resource i this http://aplikasi.muanetoraya.com/jaih/uploads/null link is probably not available
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论