ParkSangGwon / TedImagePicker

TedImagePicker is simple/beautiful/smart image picker
552 stars 103 forks source link

Not working on Android 13 #122

Closed ArtRoman closed 1 year ago

ArtRoman commented 1 year ago

No images are shown in image picker on Android 13 (API level 33), tested on emulator and real device. All is OK on other android versions, from Android 5 to 12. Where is the problem?

I've switched to Android Image Picker from support library on Android 13 because of this issue.

I see Glide errors in logcat when opening TedImagePicker activity:

02-10 03:24:31.189  7384  7384 W Glide   : Load failed for [] with dimensions [15x15]
02-10 03:24:31.189  7384  7384 W Glide   : class com.bumptech.glide.load.engine.GlideException: Failed to load resource
02-10 03:24:31.189  7384  7384 W Glide   : There was 1 root cause:
02-10 03:24:31.189  7384  7384 W Glide   : java.lang.NullPointerException(Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference)
02-10 03:24:31.189  7384  7384 W Glide   :  call GlideException#logRootCauses(String) for more detail
02-10 03:24:31.189  7384  7384 W Glide   :   Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{HierarchicalUri->Object->Drawable}, LOCAL
02-10 03:24:31.189  7384  7384 W Glide   : There was 1 root cause:
02-10 03:24:31.189  7384  7384 W Glide   : java.lang.NullPointerException(Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference)
02-10 03:24:31.189  7384  7384 W Glide   :  call GlideException#logRootCauses(String) for more detail
02-10 03:24:31.189  7384  7384 W Glide   :     Cause (1 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{HierarchicalUri->Drawable->Drawable}
02-10 03:24:31.189  7384  7384 W Glide   : There was 1 root cause:
02-10 03:24:31.189  7384  7384 W Glide   : java.lang.NullPointerException(Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference)
02-10 03:24:31.189  7384  7384 W Glide   :  call GlideException#logRootCauses(String) for more detail
02-10 03:24:31.189  7384  7384 W Glide   :       Cause (1 of 1): class java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
02-10 03:24:31.189  7384  7384 W Glide   :     Cause (2 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{HierarchicalUri->Bitmap->BitmapDrawable}
02-10 03:24:31.191  7384  7384 I Glide   : Root cause (1 of 1)
02-10 03:24:31.191  7384  7384 I Glide   : java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.resource.drawable.ResourceDrawableDecoder.handles(ResourceDrawableDecoder.java:62)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.resource.drawable.ResourceDrawableDecoder.handles(ResourceDrawableDecoder.java:28)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodePath.decodeResourceWithList(DecodePath.java:90)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodePath.decodeResource(DecodePath.java:70)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodePath.decode(DecodePath.java:59)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.LoadPath.loadWithExceptionList(LoadPath.java:76)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.LoadPath.load(LoadPath.java:57)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodeJob.runLoadPath(DecodeJob.java:539)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodeJob.decodeFromFetcher(DecodeJob.java:503)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodeJob.decodeFromData(DecodeJob.java:489)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:434)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:399)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.SourceGenerator.onDataReadyInternal(SourceGenerator.java:211)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.SourceGenerator$1.onDataReady(SourceGenerator.java:101)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.model.UnitModelLoader$UnitFetcher.loadData(UnitModelLoader.java:57)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:280)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:235)
02-10 03:24:31.191  7384  7384 I Glide   :  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
02-10 03:24:31.191  7384  7384 I Glide   :  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:421)
02-10 03:24:31.191  7384  7384 I Glide   :  at java.lang.Thread.run(Thread.java:1012)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultPriorityThreadFactory$1.run(GlideExecutor.java:380)
02-10 03:24:31.191  7384  7384 W Glide   : Load failed for [] with dimensions [147x147]
02-10 03:24:31.191  7384  7384 W Glide   : class com.bumptech.glide.load.engine.GlideException: Failed to load resource
02-10 03:24:31.191  7384  7384 W Glide   : There was 1 root cause:
02-10 03:24:31.191  7384  7384 W Glide   : java.lang.NullPointerException(Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference)
02-10 03:24:31.191  7384  7384 W Glide   :  call GlideException#logRootCauses(String) for more detail
02-10 03:24:31.191  7384  7384 W Glide   :   Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{HierarchicalUri->Object->Drawable}, LOCAL
02-10 03:24:31.191  7384  7384 W Glide   : There was 1 root cause:
02-10 03:24:31.191  7384  7384 W Glide   : java.lang.NullPointerException(Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference)
02-10 03:24:31.191  7384  7384 W Glide   :  call GlideException#logRootCauses(String) for more detail
02-10 03:24:31.191  7384  7384 W Glide   :     Cause (1 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{HierarchicalUri->Drawable->Drawable}
02-10 03:24:31.191  7384  7384 W Glide   : There was 1 root cause:
02-10 03:24:31.191  7384  7384 W Glide   : java.lang.NullPointerException(Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference)
02-10 03:24:31.191  7384  7384 W Glide   :  call GlideException#logRootCauses(String) for more detail
02-10 03:24:31.191  7384  7384 W Glide   :       Cause (1 of 1): class java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
02-10 03:24:31.191  7384  7384 W Glide   :     Cause (2 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{HierarchicalUri->Bitmap->BitmapDrawable}
02-10 03:24:31.191  7384  7384 I Glide   : Root cause (1 of 1)
02-10 03:24:31.191  7384  7384 I Glide   : java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.resource.drawable.ResourceDrawableDecoder.handles(ResourceDrawableDecoder.java:62)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.resource.drawable.ResourceDrawableDecoder.handles(ResourceDrawableDecoder.java:28)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodePath.decodeResourceWithList(DecodePath.java:90)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodePath.decodeResource(DecodePath.java:70)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodePath.decode(DecodePath.java:59)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.LoadPath.loadWithExceptionList(LoadPath.java:76)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.LoadPath.load(LoadPath.java:57)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodeJob.runLoadPath(DecodeJob.java:539)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodeJob.decodeFromFetcher(DecodeJob.java:503)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodeJob.decodeFromData(DecodeJob.java:489)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:434)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:399)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.SourceGenerator.onDataReadyInternal(SourceGenerator.java:211)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.SourceGenerator$1.onDataReady(SourceGenerator.java:101)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.model.UnitModelLoader$UnitFetcher.loadData(UnitModelLoader.java:57)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:280)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:235)
02-10 03:24:31.191  7384  7384 I Glide   :  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
02-10 03:24:31.191  7384  7384 I Glide   :  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:421)
02-10 03:24:31.191  7384  7384 I Glide   :  at java.lang.Thread.run(Thread.java:1012)
02-10 03:24:31.191  7384  7384 I Glide   :  at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultPriorityThreadFactory$1.run(GlideExecutor.java:380)

I'm also using Glide 4.14.2 in the project. Here are screenshots for Android 13 and Android 12 in emulator:

Screenshot 2023-02-10 at 03 17 15 Screenshot 2023-02-10 at 03 17 19

vaibhav142 commented 1 year ago

Not working on Android 13

hakimzulkufli commented 1 year ago

Can confirm, it's not working with Android 13.

josevsq1 commented 1 year ago

Same, it's not working on Android 13

ParkSangGwon commented 1 year ago

@ArtRoman @vaibhav142 @hakimzulkufli @josevsq1 What is your library version. And did you launch and test this demo app? Please show me your test project. And then I will check

ArtRoman commented 1 year ago

@ArtRoman @vaibhav142 @hakimzulkufli @josevsq1 What is your library version. And did you launch and test this demo app? Please show me your test project. And then I will check

I have next versions included:

    // Image picker
    implementation 'io.github.ParkSangGwon:tedimagepicker:1.4.2'
    implementation 'io.github.ParkSangGwon:tedonactivityresult:1.1.4'

The last one is to remove old android.support dependency: #121

I have found a cause of that, that can be reproduced in your demo app module. My app has minimal targetSdkVersion, it's 31 now. When compiling to targetSdkVersion 33, all is working.

Just change targetSdkVersion to 32 or 31 to get images loading errors. Glide fails to load images:

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
    at com.bumptech.glide.load.resource.drawable.ResourceDrawableDecoder.handles(ResourceDrawableDecoder.java:54)
    at com.bumptech.glide.load.resource.drawable.ResourceDrawableDecoder.handles(ResourceDrawableDecoder.java:25)
    at com.bumptech.glide.load.engine.DecodePath.decodeResourceWithList(DecodePath.java:90)
    at com.bumptech.glide.load.engine.DecodePath.decodeResource(DecodePath.java:70)
    at com.bumptech.glide.load.engine.DecodePath.decode(DecodePath.java:59)
    at com.bumptech.glide.load.engine.LoadPath.loadWithExceptionList(LoadPath.java:76)
    at com.bumptech.glide.load.engine.LoadPath.load(LoadPath.java:57)
    at com.bumptech.glide.load.engine.DecodeJob.runLoadPath(DecodeJob.java:529)
    at com.bumptech.glide.load.engine.DecodeJob.decodeFromFetcher(DecodeJob.java:493)
    at com.bumptech.glide.load.engine.DecodeJob.decodeFromData(DecodeJob.java:479)
    at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:430)
    at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:394)
    at com.bumptech.glide.load.engine.SourceGenerator.onDataReadyInternal(SourceGenerator.java:148)
    at com.bumptech.glide.load.engine.SourceGenerator$1.onDataReady(SourceGenerator.java:76)
    at com.bumptech.glide.load.model.UnitModelLoader$UnitFetcher.loadData(UnitModelLoader.java:55)
    at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:70)
    at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:63)
    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:1137)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
    at java.lang.Thread.run(Thread.java:1012)
    at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:393)

This is when app compiled to targetSdkVersion 33: Screenshot_1692638533_33

This is when app compiled to targetSdkVersion 31: Screenshot_1692638533_31

ParkSangGwon commented 1 year ago

@ArtRoman You have to use targetSdkVersion 33 If you use targetSdkVersion 32, you can not support SDK 33 version device.

If you test by under 13 OS (10, 11, 12), you can see image appear. Maybe you tested android 13 OS device.

these day, there are so many android os 13 device. So you have to use targetSdkVersion 33

ArtRoman commented 1 year ago

So you have to use targetSdkVersion 33

Ok, but you should have this requirement in documentation, because it's not obvious.

ParkSangGwon commented 1 year ago

@ArtRoman Good suggestion. I added FAQ content. https://github.com/ParkSangGwon/TedImagePicker/blob/master/README.md#--im-using-targetsdkversion-less-than-33-and-it-doesnt-work