juliansteenbakker / mobile_scanner

A universal scanner for Flutter based on MLKit. Uses CameraX on Android and AVFoundation on iOS.
BSD 3-Clause "New" or "Revised" License
756 stars 446 forks source link

App crashes in android release mode #221

Closed orliu closed 1 year ago

orliu commented 1 year ago

worked fine on debug or profile.

$ flutter doctor

[✓] Flutter (Channel stable, 3.0.0, on macOS 11.5.1 20G80 darwin-x64, locale en-AS) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 13.0) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.1) [✓] VS Code (version 1.68.1) [✓] Connected device (3 available)

$ flutter run --release

E/AndroidRuntime(22407): FATAL EXCEPTION: CameraX-core_camera_0 E/AndroidRuntime(22407): Process: com.ubisor.cloud.production_tool, PID: 22407 E/AndroidRuntime(22407): java.lang.ExceptionInInitializerError E/AndroidRuntime(22407): at androidx.camera.camera2.internal.s.(Unknown Source:149) E/AndroidRuntime(22407): at androidx.camera.camera2.internal.M.(Unknown Source:138) E/AndroidRuntime(22407): at androidx.camera.camera2.internal.t.a(Unknown Source:34) E/AndroidRuntime(22407): at m.G.b(Unknown Source:47) E/AndroidRuntime(22407): at androidx.camera.core.C.b(Unknown Source:108) E/AndroidRuntime(22407): at androidx.camera.core.A.run(Unknown Source:10) E/AndroidRuntime(22407): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) E/AndroidRuntime(22407): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) E/AndroidRuntime(22407): at java.lang.Thread.run(Thread.java:933) E/AndroidRuntime(22407): Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: m.n.values [] E/AndroidRuntime(22407): at java.lang.Enum.enumValues(Enum.java:270) E/AndroidRuntime(22407): at java.lang.Enum.access$000(Enum.java:61) E/AndroidRuntime(22407): at java.lang.Enum$1.create(Enum.java:277) E/AndroidRuntime(22407): at java.lang.Enum$1.create(Enum.java:275) E/AndroidRuntime(22407): at libcore.util.BasicLruCache.get(BasicLruCache.java:63) E/AndroidRuntime(22407): at java.lang.Enum.getSharedConstants(Enum.java:289) E/AndroidRuntime(22407): at java.lang.Class.getEnumConstantsShared(Class.java:2428) E/AndroidRuntime(22407): at java.util.EnumSet.getUniverse(EnumSet.java:407) E/AndroidRuntime(22407): at java.util.EnumSet.noneOf(EnumSet.java:109) E/AndroidRuntime(22407): at java.util.EnumSet.of(EnumSet.java:283) E/AndroidRuntime(22407): at androidx.camera.camera2.internal.r0.(Unknown Source:8) E/AndroidRuntime(22407): ... 9 more E/AndroidRuntime(22407): Caused by: java.lang.NoSuchMethodException: m.n.values [] E/AndroidRuntime(22407): at java.lang.Class.getMethod(Class.java:2072) E/AndroidRuntime(22407): at java.lang.Class.getDeclaredMethod(Class.java:2050) E/AndroidRuntime(22407): at java.lang.Enum.enumValues(Enum.java:267) E/AndroidRuntime(22407): ... 19 more

17020022033 commented 1 year ago

I also faced this problem and fixed it through edit the configuration in build.gradle.

buildTypes {
        release {
           ……
            minifyEnabled false
            shrinkResources false
        }
    }
nashihu commented 1 year ago

I'm switching from qr_code_scanner to this package because of same issue.

i still hope it is fixed without additional setting of minify and shrinkResources

juliansteenbakker commented 1 year ago

Can you please check if you have the following lines in your app's gradle file:

 compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
17020022033 commented 1 year ago

Can you please check if you have the following lines in your app's gradle file:

 compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

Yes,I do have the same compileOptions and my compileSdkVersion is 31.

nashihu commented 1 year ago

same with me

android {
    compileSdkVersion 33

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8 
    }

    .....

}
adamstyrc commented 1 year ago

Same here. I tried v 2.0.0, 2.0.0-play-services and 1.1.0. For some reason just the release build type fails.

    compileSdkVersion 32

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
juliansteenbakker commented 1 year ago

Can you please share on which device you are having this issue? I can't seem to reproduce this error.

adamstyrc commented 1 year ago

Google Pixel 5 and Pixel 6. I will try to reproduce that on example app and possibly make a PR - maybe it's just obfuscation error

On Fri, 19 Aug 2022 at 15:18, Julian Steenbakker @.***> wrote:

Can you please share on which device you are having this issue? I can't seem to reproduce this error.

— Reply to this email directly, view it on GitHub https://github.com/juliansteenbakker/mobile_scanner/issues/221#issuecomment-1220670262, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAO4B2DTQOYDLOWCJBCGS3DVZ6CSVANCNFSM5233CYYQ . You are receiving this because you commented.Message ID: @.***>

adamstyrc commented 1 year ago

UPDATE: I was going back in versioning and seems v1.1.0 is working properly. Is starts crashing from v1.1.1. Blaming change, what what CHANGELOG says, I would bet on: Update camera dependency for Android.

adamstyrc commented 1 year ago

https://github.com/juliansteenbakker/mobile_scanner/compare/v1.1.0...v1.1.1

What do you think of reverting to camera2 v1.1.0 (which is stable now - https://developer.android.com/jetpack/androidx/releases/camera ):

alg520 commented 1 year ago

v1.1.0...v1.1.1

What do you think of reverting to camera2 v1.1.0 (which is stable now - https://developer.android.com/jetpack/androidx/releases/camera ):

sound good

juliansteenbakker commented 1 year ago

This issue is probably fixed with #257. I will release this as version 3.0.0 after i'm done with a few other functions.

adamstyrc commented 1 year ago

@juliansteenbakker Great, thank you 🙌 Any clue when 3.0.0 is going to be released? I will use it immediately :)

dishankjindal1 commented 8 months ago

App is crashing for me as well on release mode. @juliansteenbakker open this issue again.