Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GlideCompose can not load "android.resource://..." #5422

Open
DHosseiny opened this issue Jun 24, 2024 · 1 comment
Open

GlideCompose can not load "android.resource://..." #5422

DHosseiny opened this issue Jun 24, 2024 · 1 comment

Comments

@DHosseiny
Copy link

DHosseiny commented Jun 24, 2024

GlideCompose can not load "android.resource://..." resources. To being specific I want to show users installed apps icons in my app that is in this format "android.resource://package_name/id_number" (ex: for youtube android.resource://com.google.android.youtube/2131820554). Usual Glide for android views(Glide.load(...).into(imageView)) works and shows this images but GlideCompose throws an exception that I wrote.

Glide Version: 4.14.2, but tested with 5rc2 too
Glide Compose Version: 1.0.0-alpha.3 but tested with beta01 too

Integration libraries: no

Device/Android Version: android 9, 13 and 14

Issue details / Repro steps / Use case background:
Just get other apps uri with this code:

val packageInfo = context.packageManager.getPackageInfo(packageName, 0)
val appUri = "android.resource://$packageName/${packageInfo.applicationInfo.icon}"
GlideImage(appUri, ...)

We have just a simple GlideModule that sets RequestOptions.format and RequestOptions.diskCacheStrategy based on device specifications. Anyway this GlideModule was present when using glide with imageView(android views) and that was working.

Layout Compose:

GlideImage(
        modifier = modifier,
        model = model,
        contentDescription = contentDescription,
        contentScale = contentScale,
        alignment = alignment,
        colorFilter = colorFilter,
        loading = placeholderResource(placeholder),
        failure = placeholderResource(failureImageRes),
    ) { builder ->
        if (hasAnimation) {
            val factory = DrawableCrossFadeFactory.Builder().setCrossFadeEnabled(true).build()
            builder.transition(DrawableTransitionOptions.withCrossFade(factory))
        }
        if (roundingRadius > 0) {
            builder.transform(RoundedCorners(roundingRadius))
        }

        builder.apply(requestBuilder)
    }

Stack trace / LogCat:

Root cause (1 of 2)
                                                                                                    java.io.FileNotFoundException: Resource does not exist: android.resource://com.google.android.youtube/2131820559
                                                                                                    	at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1850)
                                                                                                    	at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1773)
                                                                                                    	at com.bumptech.glide.load.data.FileDescriptorLocalUriFetcher.loadResource(FileDescriptorLocalUriFetcher.java:20)
                                                                                                    	at com.bumptech.glide.load.data.FileDescriptorLocalUriFetcher.loadResource(FileDescriptorLocalUriFetcher.java:12)
                                                                                                    	at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:44)
                                                                                                    	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
                                                                                                    	at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
                                                                                                    	at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
                                                                                                    	at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
                                                                                                    	at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:442)
                                                                                                    	at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:399)
                                                                                                    	at com.bumptech.glide.load.engine.SourceGenerator.onDataReadyInternal(SourceGenerator.java:211)
                                                                                                    	at com.bumptech.glide.load.engine.SourceGenerator$1.onDataReady(SourceGenerator.java:101)
                                                                                                    	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onDataReady(MultiModelLoader.java:145)
                                                                                                    	at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:45)
                                                                                                    	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
                                                                                                    	at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
                                                                                                    	at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
                                                                                                    	at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
                                                                                                    	at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:280)
                                                                                                    	at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:235)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                    	at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:424)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)
                                                                                                    	at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultPriorityThreadFactory$1.run(GlideExecutor.java:383)
2024-06-24 10:50:50.896  4200-4507  Glide                   com.farsitel.bazaar                  I  Root cause (2 of 2)
                                                                                                    java.io.FileNotFoundException: Resource does not exist: android.resource://com.google.android.youtube/2131820559
                                                                                                    	at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1850)
                                                                                                    	at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1773)
                                                                                                    	at com.bumptech.glide.load.data.AssetFileDescriptorLocalUriFetcher.loadResource(AssetFileDescriptorLocalUriFetcher.java:20)
                                                                                                    	at com.bumptech.glide.load.data.AssetFileDescriptorLocalUriFetcher.loadResource(AssetFileDescriptorLocalUriFetcher.java:11)
                                                                                                    	at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:44)
                                                                                                    	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
                                                                                                    	at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
                                                                                                    	at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
                                                                                                    	at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
                                                                                                    	at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherFailed(DecodeJob.java:416)
                                                                                                    	at com.bumptech.glide.load.engine.SourceGenerator.onLoadFailedInternal(SourceGenerator.java:223)
                                                                                                    	at com.bumptech.glide.load.engine.SourceGenerator$1.onLoadFailed(SourceGenerator.java:108)
                                                                                                    	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:167)
                                                                                                    	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:154)
                                                                                                    	at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:50)
                                                                                                    	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
                                                                                                    	at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
                                                                                                    	at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
                                                                                                    	at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
                                                                                                    	at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:442)
                                                                                                    	at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:399)
                                                                                                    	at com.bumptech.glide.load.engine.SourceGenerator.onDataReadyInternal(SourceGenerator.java:211)
                                                                                                    	at com.bumptech.glide.load.engine.SourceGenerator$1.onDataReady(SourceGenerator.java:101)
                                                                                                    	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onDataReady(MultiModelLoader.java:145)
                                                                                                    	at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:45)
                                                                                                    	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
                                                                                                    	at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
                                                                                                    	at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
                                                                                                    	at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
                                                                                                    	at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:280)
                                                                                                    	at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:235)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                    	at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:424)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)
                                                                                                    	at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultPriorityThreadFactory$1.run(GlideExecutor.java:383)

Screenshot_20240624_110202_Bazaar

@hfkai
Copy link

hfkai commented Oct 30, 2024

你这个路径不对

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants