класса com.bumptech .glide.load.engine.GlideException: не удалось загрузить ресурс
Причина (1 из 1): класс com.bumptech.glide.load.engine.GlideException: ошибка LoadPath{StringUri->Object->Drawable}, ЛОКАЛЬНАЯ
Причина (1 из 2): класс com.bumptech.glide.load.engine.GlideException: ошибка DecodePath{StringUri->Drawable->DrawableПричина (2 из 2): класс com.bumptech.glide.load.engine.GlideException: не удалось DecodePath{StringUri->Bitmap->BitmapDrawable
Это код
String imageUrl = obj.getUrl();
Код: Выделить всё
if (imageUrl != null && !imageUrl.isEmpty()) {
// Convertir la URL en un Uri
Uri imageUri = Uri.parse(imageUrl);
Log.d("CargaCarrusel", "URL de la imagen: " + imageUrl);
Log.d("CargaCarrusel", "URI convertida: " + imageUri);
try {
Glide.with(this)
.load(imageUri)
.apply(new RequestOptions().override(400,400))
.centerCrop()// Cargar la imagen desde la URL
.into(img); // Cargar en el ImageView
Log.d("CargaCarrusel", "Imagen cargada correctamente desde la URL.");
} catch (Exception e) {
// Capturar cualquier excepción en el proceso de carga de la imagen
Log.e("CargaCarrusel", "Error al cargar la imagen con Glide desde la URL: " + imageUrl, e);
img.setImageResource(R.drawable.avatarvacio); // Establecer imagen por defecto en caso de error
}
} else {
// Si la URL es nula o vacía, cargar la imagen por defecto
Log.e("CargaCarrusel", "URL de la imagen es nula o vacía, cargando imagen por defecto.");
Glide.with(this)
.load(R.drawable.avatarvacio) // Cargar una imagen de placeholder si no hay URL
.into(img); // Cargar en el ImageView
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... ry-to-load
Мобильная версия