Skip to content

Commit

Permalink
bug: Fixing camera barcode crash
Browse files Browse the repository at this point in the history
Barcode feature was crashing with exception (java.lang.AbstractMethodError: abstract method "android.util.Size androidx.camera.core.ImageAnalysis$Analyzer.getDefaultTargetResolution()") on some project with release configuration.

The issue is not clear why it's happening but as fix for it we forced overriding the fun getDefaultTargetResolution() and return a kotlin default value.
  • Loading branch information
smellouk committed May 26, 2023
1 parent 1e3cf20 commit bcf3f0a
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.nyris.sdk.camera.feature.barcode

import android.util.Size
import androidx.camera.core.ImageAnalysis
import androidx.camera.core.ImageProxy
import androidx.camera.core.UseCase
Expand Down Expand Up @@ -47,9 +48,7 @@ class BarcodeImageFeature internal constructor(
) : ImageFeature<BarcodeResultInternal> {
init {
imageAnalysisWrapper.apply {
setAnalyzer(imageAnalysisExecutor) { imageProxy ->
processImageProxy(imageProxy)
}
setAnalyzer(imageAnalysisExecutor, BarcodeAnalyzer())
}
}

Expand Down Expand Up @@ -94,6 +93,15 @@ class BarcodeImageFeature internal constructor(
private fun Barcode.toBarcodeInternal() =
BarcodeInternal(code = this.rawValue, format = this.format.toBarcodeFormat())

inner class BarcodeAnalyzer: ImageAnalysis.Analyzer {
override fun getDefaultTargetResolution(): Size? {
return null
}
override fun analyze(imageProxy: ImageProxy) {
processImageProxy(imageProxy)
}
}

companion object {
@Suppress("SpreadOperator") // Small Array
fun createInstance(
Expand Down

0 comments on commit bcf3f0a

Please sign in to comment.