yushulx / flutter_barcode_sdk

Build barcode QR detection apps for Windows, Linux, macOS, Android, iOS and web.
https://pub.dev/packages/flutter_barcode_sdk
MIT License
47 stars 18 forks source link

Flutter barcode SDK crashs my release of the app #8

Closed nimr77 closed 3 years ago

nimr77 commented 3 years ago

this is my flutter doctor

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.0.5, on Linux, locale en_US.UTF-8) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [✓] Chrome - develop for the web and everything is working well, but the plugin adds about 18 mega to the app release size, and crush it when we open it.

yushulx commented 3 years ago

@nimr77 Android or web? Can you provide detailed information?

nimr77 commented 3 years ago

@nimr77 Android or web? Can you provide detailed information?

Yes, it's on android level 23, I have loved your plugin so much, but the size and the crash blocked me

yushulx commented 3 years ago

@nimr77 can you provide the crash log?

nimr77 commented 3 years ago

@nimr77 can you provide the crash log?

How it's on the release only, The app just crashed

yushulx commented 3 years ago

@nimr77 it seems to be a known issue caused by Flutter release build. I've solved the issue by disabling minifyEnabled and shrinkResources in build.gradle

buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
            minifyEnabled false
            shrinkResources false
        }
    }

You can then build the apk with the following command to shrink the apk size:

flutter build apk --release --split-per-abi

image

nimr77 commented 3 years ago

@nimr77 it seems to be a known issue caused by Flutter release build. I've solved the issue by disabling minifyEnabled and shrinkResources in build.gradle

buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
            minifyEnabled false
            shrinkResources false
        }
    }

You can then build the apk with the following command to shrink the apk size:

flutter build apk --release --split-per-abi

image

So in order to use the plug-in I must disable the minify and the shrink resources, and what about deploying the result shrinks, I have ended up using another plug-in.

yushulx commented 3 years ago

@nimr77 I've found the perfect workaround. You just need to add -keep class com.dynamsoft.dbr.** { *; } to proguard-rules.pro, and edit the build.gradle file:

buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
yushulx commented 3 years ago

@nimr77 I've updated the repo and pushed a new version to pub.dev. I think I can close the issue now. Thanks for your feedback.