mintware-de / flutter_barcode_reader

A flutter plugin for reading 2D barcodes and QR codes.
MIT License
628 stars 463 forks source link

No implementation for method requestCameraPermission ( 3.0.0-dev.3) #211

Closed djlegge closed 4 years ago

djlegge commented 4 years ago

Hi Using the new version 3.0.0-dev.3 for Android, it works very well in the debug build but if I build an app bundle to test the release build I get "MissingPluginException(No implementation found for method requestCameraPermission on channel de.mintware.barcode_scan)". This happens every time you try a scan. Any ideas ? Thanks...

devtronic commented 4 years ago

Please provide a minimal working example to reproduce the problem. Are you using proguard?

djlegge commented 4 years ago

Thanks for the quick response ! Double checking everything this morning, flutter run --release DOES work - the app asks for the camera permissions etc. The problem is when you build app bundle or apks and install them outside of flutter. The flutter_barcode_reader example project does the same thing.

flutter build apk
adb install build/app/outputs/apk/release/app-release.apk 

... does not work. It seems I am using proguard as it is the default. Building the apk's or bundle with the --no-shrink option fixes the problem.

devtronic commented 4 years ago

Please try to add -keep class de.mintware.** { *; } to your proguard rules and tell if it works. Maybe it's because some methods in the platform code are executed by reflection instead of invoking them directly. This will be probably recognized as "dead code" in the release build.

djlegge commented 4 years ago

Yes, that works. I had to create the android/app/proguard-rules.pro file as it didn't exist. I did not myself enable proguard, it's R8 that is enabled by default apparently. Anyway, thanks so much for your help and for this great package library.

devtronic commented 4 years ago

Perfect, thanks for the information! I'll check if I can create a proguard-rules.pro file for the package so users don't need to activate it by them self. If it's not possible I'll update the docs!

devtronic commented 4 years ago

The latest version (3.0.0) contains a fix for the problem so you don't need to add the rule to the proguard file.