bumptech / glide

An image loading and caching library for Android focused on smooth scrolling
https://bumptech.github.io/glide/
Other
34.67k stars 6.12k forks source link

Fatal Exception: android.content.res.Resources$NotFoundException: Resource ID #0x7f08006c #4903

Open epegasus opened 2 years ago

epegasus commented 2 years ago

Glide Version: 4.13.2

Integration libraries: none of above

Device/Android Version:

Brand: Samsung Model: Galaxy J2 Core Orientation: Portrait RAM free: 224.71 MB Disk free: 690.37 MB Operating System (Version:Android 8.1.0)

Issue details / Repro steps / Use case background:

Glide load line / GlideModule (if any) / list Adapter code (if any):

@BindingAdapter("imageUri")
fun ShapeableImageView.setImageFromUri(imageUri: Uri?) {
    Glide
        .with(this)
        .load(imageUri)
        .placeholder(R.drawable.bg_glide)
        .transition(DrawableTransitionOptions.withCrossFade(100))
        .into(this)
}

Layout XML:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

        <variable
            name="imageUri"
            type="android.net.Uri" />
    </data>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.google.android.material.imageview.ShapeableImageView
            android:id="@+id/siv_image_List_Item_Home_Slider"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:adjustViewBounds="true"
            android:scaleType="fitXY"
            app:imageUri="@{imageUri}"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintDimensionRatio="4.7:3"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            tools:srcCompat="@drawable/dummy" />

    </androidx.constraintlayout.widget.ConstraintLayout>

</layout>

Stack trace / LogCat:

Fatal Exception: android.content.res.Resources$NotFoundException: Resource ID #0x7f08006c
       at android.content.res.ResourcesImpl.getValueForDensity(ResourcesImpl.java:224)
       at android.content.res.Resources.getDrawableForDensity(Resources.java:876)
       at android.content.res.Resources.getDrawable(Resources.java:819)
       at androidx.core.content.res.ResourcesCompat$Api21Impl.getDrawable(ResourcesCompat.java)
       at androidx.core.content.res.ResourcesCompat.getDrawable(ResourcesCompat.java:58)
       at com.bumptech.glide.load.resource.drawable.DrawableDecoderCompat.loadDrawableV4(DrawableDecoderCompat.java:58)
       at com.bumptech.glide.load.resource.drawable.DrawableDecoderCompat.getDrawable(DrawableDecoderCompat.java:58)
       at com.bumptech.glide.load.resource.drawable.DrawableDecoderCompat.getDrawable(DrawableDecoderCompat.java:16)
       at com.bumptech.glide.request.SingleRequest.loadDrawable(SingleRequest.java:16)
       at com.bumptech.glide.request.SingleRequest.getPlaceholderDrawable(SingleRequest.java:17)
       at com.bumptech.glide.request.SingleRequest.begin(SingleRequest.java:178)
       at com.bumptech.glide.manager.RequestTracker.runRequest(RequestTracker.java:96)
       at com.bumptech.glide.RequestManager.track(RequestManager.java:96)
       at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java:96)
       at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java:124)
       at photocollage.photoeditor.layout.collagemaker.photo.grid.helper.adapters.binding.ImageBindingAdapterKt.setImageFromDrawable(ImageBindingAdapterKt.java:45)
       at photocollage.photoeditor.layout.collagemaker.photo.grid.databinding.ListItemHomeSliderBindingImpl.executeBindings(ListItemHomeSliderBindingImpl.java:19)
       at androidx.databinding.ViewDataBinding.executeBindingsInternal(ViewDataBinding.java:19)
       at androidx.databinding.ViewDataBinding.executePendingBindings(ViewDataBinding.java:52)
       at androidx.databinding.ViewDataBinding$7.run(ViewDataBinding.java:52)
       at androidx.databinding.ViewDataBinding$8.doFrame(ViewDataBinding.java:5)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:909)
       at android.view.Choreographer.doCallbacks(Choreographer.java:723)
       at android.view.Choreographer.doFrame(Choreographer.java:655)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
       at android.os.Handler.handleCallback(Handler.java:790)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6543)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
sjudd commented 2 years ago

Does it work if you just call ResourcesCompat.getDrawable directly?

janbolat commented 1 year ago

This is not related to the library, please see this: https://stackoverflow.com/questions/64693616/resourcesnotfoundexception-when-launching-splashscreen

We are also facing the same problem with drawables on this device.