BitmapFactory.decodeFile(absolutePath, this) must not be null
Implementation:
val originalPhotoFile = File(originalPhotoPath ?: return)
lifecycleScope.launch {
val compressedPhotoPath = Compressor.compress(requireContext(),originalPhotoFile)
}
Exception:
Fatal Exception: java.lang.IllegalStateException: BitmapFactory.decodeFile…eFile.absolutePath, this) must not be null
at id.zelory.compressor.UtilKt.decodeSampledBitmapFromFile(Util.kt:45)
at id.zelory.compressor.constraint.DefaultConstraint.satisfy(DefaultConstraint.kt:28)
at id.zelory.compressor.Compressor$compress$3.invokeSuspend(Compressor.kt:28)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Same issue on multiple Xiaomi devices and a P30 Pro for now .... 👎🏻
Is there anything we can do to prevent this crash ?
@r4phab Currently, as a workaround, we have created an extension function to fall back to the uncompressed file in case of an exception but this should be fixed.
is this issue has fix version ?
is it fixed version now?
still issue occurs.
Still facing this issue.
This might be happened, if we try to create a temporary file (not an image type).
In our case:
- we make sure when creating temporary files (before take picture/open camera)
- 1do nothing for the files (no compression)
- afterward
onActivityResultcalled, theUrinow used either to update the previous temporary files or try to compress theUri(convert it to aFilefirst)
This is also sometimes related to Android 10 & above permission, when trying to open/retrieve files from /Android/data, as mentioned in here: https://developer.android.com/about/versions/11/privacy/storage#file-access
Any updates on this?
Still have the issue