Android-Image-Cropper icon indicating copy to clipboard operation
Android-Image-Cropper copied to clipboard

Android 11 Pixel 2

Open donhill opened this issue 5 years ago • 14 comments

I have a working app on most devices. It's been out for a few years. I recently upgraded the phone to Android 11 and the API to 29. I am noticing some behavior with the camera. When I use the camera and then fire the start cropping, there is no image in the CropActivity.

Has anyone experienced this and aware of the fix?

donhill avatar Sep 14 '20 21:09 donhill

try this : added android:requestLegacyExternalStorage="true" in AndroidManifest.xml

<application android:requestLegacyExternalStorage="true" .../>

moonfalling avatar Sep 17 '20 04:09 moonfalling

android:requestLegacyExternalStorage="true" does no longer work from Android 11. I met the same problem on the emulator running Android 11.

If I set "targetSdkVersion = 29", I can see image source selection, and after then picked camera option, I can not see taken picture file. Even more, If I set "targetSdkVersion = 30", I can not even see any option of the image source selection.

kyungin-park avatar Sep 17 '20 23:09 kyungin-park

To followup on this I was able to get the error when coming back from taking a picture. The image selection works fine.

java.lang.RuntimeException: Failed to load sampled bitmap: file:///storage/emulated/0/Android/data/com.example/cache/pickImageResult.jpeg File is not a picture

donhill avatar Sep 22 '20 18:09 donhill

I can reproduce it in my physical Google Pixel 4 device, and also in Android emulator of Pixel 3a, on API 30.

When debugging, seems like inside the function getCaptureImageOutputUri() in CropImage.java, context.getExternalCacheDir(); is returning null

Not really sure whether is API related but some folks on stackoverflow says that:

This can also happen if you're running on a device or emulator without any external storage.

Which could be why Pixel devices are having issues.

iori57 avatar Oct 30 '20 02:10 iori57

please check this

Canato avatar Nov 16 '20 21:11 Canato

Reading writing images from external memory is not allowed in android 11. If someone find a solution please do share.

farrakhj avatar Nov 21 '20 17:11 farrakhj

Hey!

I start a new project to handover this library https://github.com/CanHub/Android-Image-Cropper

The ideia is that we keep improving because this project don’t have updates since 2018 Hope I can count with your help.

Open to contribute, next pieces of work will be Android 11 permissions, refactor into Kotlin and ActivityContract

Canato avatar Nov 27 '20 16:11 Canato

To followup on this I was able to get the error when coming back from taking a picture. The image selection works fine.

java.lang.RuntimeException: Failed to load sampled bitmap: file:///storage/emulated/0/Android/data/com.example/cache/pickImageResult.jpeg File is not a picture

Did you find any solution for this ? I am getting same issue for Camera selection,

jagdeepmohd avatar Feb 23 '21 13:02 jagdeepmohd

To followup on this I was able to get the error when coming back from taking a picture. The image selection works fine.

java.lang.RuntimeException: Failed to load sampled bitmap: file:///storage/emulated/0/Android/data/com.example/cache/pickImageResult.jpeg File is not a picture

Did you find any solution for this ? I am getting same issue for Camera selection,

@jagdeepmohd Please check the new library, I believe this was fixed.

https://github.com/CanHub/Android-Image-Cropper

Canato avatar Feb 23 '21 16:02 Canato

To followup on this I was able to get the error when coming back from taking a picture. The image selection works fine. java.lang.RuntimeException: Failed to load sampled bitmap: file:///storage/emulated/0/Android/data/com.example/cache/pickImageResult.jpeg File is not a picture

Did you find any solution for this ? I am getting same issue for Camera selection,

@jagdeepmohd Please check the new library, I believe this was fixed.

https://github.com/CanHub/Android-Image-Cropper

In Android 11 Uri lacks 'file' scheme: content: //packagename.cropper.fileprovider/my_images/Pictures/imagename.jpg

baonq-2356 avatar Mar 02 '21 05:03 baonq-2356

@baonq-2356 Thanks for reply. Issue is resolved with new library.

jagdeepmohd avatar Mar 02 '21 05:03 jagdeepmohd

@jagdeepmohd i try with library: https://github.com/CanHub/Android-Image-Cropper version 2.1.1 then get that error so, what is newest library?

baonq-2356 avatar Mar 02 '21 05:03 baonq-2356

@jagdeepmohd i try with library: https://github.com/CanHub/Android-Image-Cropper version 2.1.1 then get that error so, what is newest library?

sorry, i has confused, this isn't your library issue ^^

baonq-2356 avatar Mar 02 '21 05:03 baonq-2356

If something is wrong or odd on the CanHub lib please open a issue so we can tackle it ;)

Canato avatar Mar 02 '21 08:03 Canato