26

i am using https://github.com/jhansireddy/AndroidScannerDemo this scan library in my project.

when i capture image i am getting D/skia: --- Failed to create image decoder with message 'unimplemented' in console and The captured image not sets to imageview in Android P.

also when i am testing same app in Android Q i am getting below error.

2020-02-05 11:32:23.668 9270-9270/? E/ReviewScreenImpl: onClickOKButton() - Fail to decode captured picture

Can someone please help on above issues.

Ajinkya kadam
  • 542
  • 1
  • 6
  • 16

4 Answers4

3

I have the same problem and it seems there is a bug in getResources not in library you used because I don`t use it. but, you can use ResourcesCompat instead, like this:

val myLogo = (ResourcesCompat.getDrawable(this.resources, R.drawable.ic_home_black_24dp, null) as VectorDrawable).toBitmap()

or

val myLogo = (ResourcesCompat.getDrawable(this.resources, R.drawable.ic_home_black_24dp, null) as BitmapDrawable).bitmap

depend on your drawable type(vector or image).

be aware that this will only run on API > 22.

kAvEh
  • 534
  • 4
  • 15
0

Make sure you have generated the image Uri which you will be sending with Intent to the camera app with the FileProvider.

The image uri where the camera app will save the picture before returning Activity.RESULT_OK should be generated with FileProvider like this

FileProvider.getUriForFile(
        context,
        context.getString(R.string.file_sharing_authority),
        File(filePath)

For more information about how to share our file to other apps (like the camera app) to be read or written into, see https://developer.android.com/reference/androidx/core/content/FileProvider

Sundaravel
  • 464
  • 5
  • 16
0

This bug originates from Android Studio emulator and probably has nothing to do with the API/library you choose, whether in native Android or Flutter. I had this problem once in a while, where it only took place in emulator. All network/online pictures can't be displayed on app and above error messages were shown all over the place. My app ran fine on my USB connected phone though.

Updating/redownloading the image for the emulator fixed the issue.

Daniel Wu
  • 124
  • 1
  • 9
-1

Please pass the image byte string, instead of passing a simple string, into your decoder BitmapFactory.decodeStream method.

auspicious99
  • 3,902
  • 1
  • 44
  • 58