juliuscanute / qr_code_scanner

QR Code Scanner for Flutter
BSD 2-Clause "Simplified" License
1k stars 777 forks source link

[BUG] Crash on device android #420

Open hphuc613 opened 3 years ago

hphuc613 commented 3 years ago

``My app working fine on emulator, but I build apk release and install in any physical device is crash and out the app when open camera. Please help me. With error:

E/AndroidRuntime(27497): FATAL EXCEPTION: main
E/AndroidRuntime(27497): Process: com.baseproject.lumas, PID: 27497
E/AndroidRuntime(27497): java.lang.RuntimeException: java.lang.NoSuchMethodException: c.b.d.e.values []
MTM-A commented 3 years ago

I have the same problem too. is a solution foreseen in a short time?

hphuc613 commented 3 years ago

I have the same problem too. is a solution foreseen in a short time?

https://stackoverflow.com/questions/54847976/java-lang-assertionerror-impossible-caused-by-java-lang-nosuchmethodexception I see solution in case it relate to proguard

greenking19 commented 3 years ago

I have the same problem too. is a solution foreseen in a short time?

https://stackoverflow.com/questions/54847976/java-lang-assertionerror-impossible-caused-by-java-lang-nosuchmethodexception I see solution in case it relate to proguard

🤔 Hello, I don't understand this solution a bit, where is the proguard in the flutter project. I am not very familiar with andorid

hphuc613 commented 3 years ago

I have the same problem too. is a solution foreseen in a short time?

https://stackoverflow.com/questions/54847976/java-lang-assertionerror-impossible-caused-by-java-lang-nosuchmethodexception I see solution in case it relate to proguard

🤔 Hello, I don't understand this solution a bit, where is the proguard in the flutter project. I am not very familiar with andorid

https://stackoverflow.com/questions/52428973/how-to-minify-a-flutter-app-with-proguard Please, add file proguard like solution.

itkun2013 commented 3 years ago

me too ,debug is ok ,but release crash

greenking19 commented 3 years ago

me too ,debug is ok ,but release crash

爱坤,我找到问题了, 再打开二维码的时候收起键盘就可以了。

Geowan commented 3 years ago

For those still experiencing the crash in release but debug is okay, the issue is been caused by when building a release process in gradle. The way i was able to fix is is by

  1. add the following to the android/app/build.gradle

    buildTypes { release { signingConfig signingConfigs.release

        minifyEnabled true
        useProguard true
    
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    
    }

    }

The on the same path create a file proguard-rules.pro and add the following in it

    #Flutter Wrapper
    -keep class io.flutter.app.** { *; }
    -keep class io.flutter.plugin.**  { *; }
    -keep class io.flutter.util.**  { *; }
    -keep class io.flutter.view.**  { *; }
    -keep class io.flutter.**  { *; }
    -keep class io.flutter.plugins.**  { *; }
    -keepclassmembers enum * {
       public static **[] values();
       public static ** valueOf(java.lang.String); 
    }

This was able to fix my issue

xncz8h commented 2 years ago

For those still experiencing the crash in release but debug is okay, the issue is been caused by when building a release process in gradle. The way i was able to fix is is by

  1. add the following to the android/app/build.gradle

    buildTypes {
    release {
        signingConfig signingConfigs.release
    
        minifyEnabled true
        useProguard true
    
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    
    }

    }

The on the same path create a file proguard-rules.pro and add the following in it

    #Flutter Wrapper
    -keep class io.flutter.app.** { *; }
    -keep class io.flutter.plugin.**  { *; }
    -keep class io.flutter.util.**  { *; }
    -keep class io.flutter.view.**  { *; }
    -keep class io.flutter.**  { *; }
    -keep class io.flutter.plugins.**  { *; }
    -keepclassmembers enum * {
       public static **[] values();
       public static ** valueOf(java.lang.String); 
    }

This was able to fix my issue

This worked for us. However, we had to remove the line "useProguard true". This caused build errors