bumptech / glide

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

NullPointerException: java.util.Collections$UnmodifiableCollection.<init>(Collections.java:1073) #5317

Open sjxxcode opened 10 months ago

sjxxcode commented 10 months ago

Glide Version: 4.16.0

Integration libraries: okHttp3-4.11.0

Device/Android Version: tablet, version 12

Issue details / Repro steps / Use case background:

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

Glide.with(fragment instance).load(background res id).into(CustomViewTargetImp(this))

class CustomViewTargetImp(view: FrameLayout) : CustomViewTarget<FrameLayout, Drawable>(view) {
        override fun onLoadFailed(errorDrawable: Drawable?) {
        }

        override fun onResourceCleared(placeholder: Drawable?) {

        }

        override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) {
            view.background = resource
        }

    }

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">

    <FrameLayout
        android:id="@+id/content_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/transparent">

    </FrameLayout>
</layout>

Stack trace / LogCat:


java.lang.ExceptionInInitializerError    
at com.bumptech.glide.Glide.<init>(Glide.java:415)    
at com.bumptech.glide.GlideBuilder.build(GlideBuilder.java:563)    
at com.bumptech.glide.Glide.initializeGlide(Glide.java:314)    
at com.bumptech.glide.Glide.initializeGlide(Glide.java:266)    
at com.bumptech.glide.Glide.checkAndInitializeGlide(Glide.java:210)    
at com.bumptech.glide.Glide.get(Glide.java:191)    
at com.bumptech.glide.Glide.getRetriever(Glide.java:774)    
at com.bumptech.glide.Glide.with(Glide.java:838)    
at com.xx.xxFragment$initElements$1.invokeSuspend(SubjectFragment.kt:71)    
at com.xx.xxFragment$initElements$1.invoke(Unknown Source:8)    
at com.xx.xxFragment$initElements$1.invoke(Unknown Source:2)    
at com.zuoyebang.iot.pad.launcher.LauncherExtKt$delaySuspendThings$1.invokeSuspend(LauncherExt.kt:448)    
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)    
at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:234)    
at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:166)    
at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:397)    
at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:431)    
at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:420)    
at kotlinx.coroutines.CancellableContinuationImpl.resumeUndispatched(CancellableContinuationImpl.kt:518)    
at kotlinx.coroutines.android.HandlerContext$scheduleResumeAfterDelay$$inlined$Runnable$1.run(Runnable.kt:19)    
at android.os.Handler.handleCallback(Handler.java:938)    
at android.os.Handler.dispatchMessage(Handler.java:99)    
at android.os.Looper.loopOnce(Looper.java:201)    
at android.os.Looper.loop(Looper.java:288)    
at android.app.ActivityThread.main(ActivityThread.java:7881)    
at java.lang.reflect.Method.invoke(Native Method)    
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)    
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)    
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@83ac131, Dispatchers.Main]    
Caused by: java.lang.NullPointerException    
at java.util.Collections$UnmodifiableCollection.<init>(Collections.java:1073)    
at java.util.Collections$UnmodifiableSet.<init>(Collections.java:1175)    
at java.util.Collections.unmodifiableSet(Collections.java:1165)    
at com.bumptech.glide.load.resource.bitmap.Downsampler.<clinit>(Downsampler.java:130)    
at com.bumptech.glide.Glide.<init>(Glide.java:415)    
at com.bumptech.glide.GlideBuilder.build(GlideBuilder.java:563)    
at com.bumptech.glide.Glide.initializeGlide(Glide.java:314)    
at com.bumptech.glide.Glide.initializeGlide(Glide.java:266)    
at com.bumptech.glide.Glide.checkAndInitializeGlide(Glide.java:210)    
at com.bumptech.glide.Glide.get(Glide.java:191)    
at com.bumptech.glide.Glide.getRetriever(Glide.java:774)    
at com.bumptech.glide.Glide.with(Glide.java:838)    
at com.xx.xxFragment$initElements$1.invokeSuspend(SubjectFragment.kt:71)    
at com.xx.xxFragment$initElements$1.invoke(Unknown Source:8)    
at com.xx.xxFragment$initElements$1.invoke(Unknown Source:2)    
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)    
at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:234)    
at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:166)    
at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:397)    
at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:431)    
at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:420)    
at kotlinx.coroutines.CancellableContinuationImpl.resumeUndispatched(CancellableContinuationImpl.kt:518)    
at kotlinx.coroutines.android.HandlerContext$scheduleResumeAfterDelay$$inlined$Runnable$1.run(Runnable.kt:19)    
at android.os.Handler.handleCallback(Handler.java:938)    
at android.os.Handler.dispatchMessage(Handler.java:99)    
at android.os.Looper.loopOnce(Looper.java:201)    
at android.os.Looper.loop(Looper.java:288)    
at android.app.ActivityThread.main(ActivityThread.java:7881)    
at java.lang.reflect.Method.invoke(Native Method)    
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)    
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)   
sjxxcode commented 10 months ago

@sjudd May I ask what is the cause of the above problem?