英文:
Glide does not load images
问题
我的代码是标准的:
options = options.transforms(CenterCrop(), RoundedCorners(3.px))
Glide.with(itemView.context).load(flower.profilePicture.prefixHttp())
.apply(options)
.transition(
DrawableTransitionOptions.withCrossFade()
).into(flowerImage)
我进行了调试并获得了以下信息:
flower.profilePicture.prefixHttp() = http://flowrspot.s3.amazonaws.com/flowers/profile_pictures/000/000/007/medium/L_00010.jpg?1527514226
这是完全正常的。我尝试了多个依赖项:
// implementation 'com.github.bumptech.glide:glide:4.8.0';
// kapt 'com.github.bumptech.glide:compiler:4.8.0';
implementation 'com.github.bumptech.glide:glide:4.14.2';
annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2';
但它仍然无法加载。在我的Logcat中,我收到一些警告/错误信息:
"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"
"Load failed for [http://flowrspot.s3.amazonaws.com/flowers/profile_pictures/000/000/007/medium/L_00010.jpg?1527514226] with dimensions [420x525]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
There was 1 root cause:
com.bumptech.glide.load.HttpException(Failed to connect or obtain data, status code: -1)
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 root cause:
com.bumptech.glide.load.HttpException(Failed to connect or obtain data, status code: -1)
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed
There was 1 root cause:
com.bumptech.glide.load.HttpException(Failed to connect or obtain data, status code: -1)
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class com.bumptech.glide.load.HttpException: Failed to connect or obtain data, status code: -1"
这里发生了什么情况。从未见过Glide表现得像这样...
英文:
My code is standard:
options = options.transforms(CenterCrop(), RoundedCorners(3.px))
Glide.with(itemView.context).load(flower.profilePicture.prefixHttp())
.apply(options)
.transition(
DrawableTransitionOptions.withCrossFade()
).into(flowerImage)
I debugged and get
flower.profilePicture.prefixHttp() = http://flowrspot.s3.amazonaws.com/flowers/profile_pictures/000/000/007/medium/L_00010.jpg?1527514226
which is totally fine. I tried with multiple dependencies:
// implementation 'com.github.bumptech.glide:glide:4.8.0'
// kapt 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.github.bumptech.glide:glide:4.14.2'
annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2'
But it just does not load. In my logcat I get some warnings/errors written:
"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"
"Load failed for [http://flowrspot.s3.amazonaws.com/flowers/profile_pictures/000/000/007/medium/L_00010.jpg?1527514226] with dimensions [420x525]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
There was 1 root cause:
com.bumptech.glide.load.HttpException(Failed to connect or obtain data, status code: -1)
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 root cause:
com.bumptech.glide.load.HttpException(Failed to connect or obtain data, status code: -1)
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed
There was 1 root cause:
com.bumptech.glide.load.HttpException(Failed to connect or obtain data, status code: -1)
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class com.bumptech.glide.load.HttpException: Failed to connect or obtain data, status code: -1"
What is going on here. Never seen glide behave like this...
答案1
得分: 1
通过在Android应用的AndroidManifest.xml
文件中将usesCleartextTraffic
属性设置为true
,允许应用向HTTP(非HTTPS)URL发出网络请求。
因为从Android 9(Pie)开始,默认值usesCleartextTraffic
为false(禁用),这意味着应用不被允许向HTTP URL发出网络请求。
英文:
By setting the usesCleartextTraffic
attribute to true
in your Android app's AndroidManifest.xml
file allows the app to make network requests to HTTP (non-HTTPS) URLs.
Because, starting from Android 9 (Pie), the default value of usesCleartextTraffic
is false (disabled), which means that apps are not allowed to make network requests to HTTP URLs.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论