Glide.with(this).load("https://www.baidu.com/img/bdlogo.png").skipMemoryCache(false).diskCacheStrategy(DiskCacheStrategy.ALL).error(R.drawable.gantanhao) .centerCrop().into(iv);
加载一直不能正常加载网络图片 ,都是加载error中的图片,
改为监听错误状态:
Glide.with(this).load("https://www.baidu.com/img/bdlogo.png").listener(new RequestListener() {
@Override
public boolean onException(Exception e, String model, Target target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target target, boolean isFromMemoryCache, boolean isFirstResource) {
return false;
}
}).skipMemoryCache(false).diskCacheStrategy(DiskCacheStrategy.ALL).error(R.drawable.gantanhao) .centerCrop().into(iv);
添加listener,断点得到错误e值:
result = {java.lang.SecurityException@4410} "java.lang.SecurityException: Permission denied (missing INTERNET permission?)"
cause = {android.system.GaiException@4424} "android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)"
detailMessage = "Permission denied (missing INTERNET permission?)"
stackState = {int[62]@4426}
stackTrace = {java.lang.StackTraceElement[0]@4427}
suppressedExceptions = {java.util.Collections$EmptyList@4428} size = 0
shadow$_klass_ = {java.lang.Class@503} "class java.lang.SecurityException"
shadow$_monitor_ = -2084365041
然后发现错误位置,ok,INTERNET权限放在application外