ArthurHub / Android-Image-Cropper

Image Cropping Library for Android, optimized for Camera / Gallery.
Apache License 2.0
6.39k stars 1.36k forks source link

Android 11 Pixel 2 #783

Open donhill opened 3 years ago

donhill commented 3 years ago

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?

moonfalling commented 3 years ago

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

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

kyungin-park commented 3 years ago

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.

donhill commented 3 years ago

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

iori57 commented 3 years ago

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.

Canato commented 3 years ago

please check this

farrakhj commented 3 years ago

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

Canato commented 3 years ago

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

jagdeepmohd commented 3 years ago

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,

Canato commented 3 years ago

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

baonq-2356 commented 3 years ago

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

jagdeepmohd commented 3 years ago

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

baonq-2356 commented 3 years ago

@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 commented 3 years ago

@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 ^^

Canato commented 3 years ago

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