cordova-plugin-qrscanner icon indicating copy to clipboard operation
cordova-plugin-qrscanner copied to clipboard

FATAL Error when cancel/destroy Scanner window on android

Open markusweb opened this issue 5 years ago • 2 comments

i use

  • cordova-plugin-qrscanner 3.0.1 "QRScanner"
  • platform android 8.1.0
  • android platform_tools 29.0.4

i had the problem, that when hitting cancel in scanner window my app crashed with a FATAL ERROR in line 781. this is in the destry function. the first cancel was mostly working but then all other will lead to the FATAL ERROR.

as a work-a-round i check if mBarcodeView.getParent() is not null... this seems to help. my app does not crash anymore...

QRScanner.java

private void destroy(CallbackContext callbackContext) {
(...)
 if(cameraPreviewing) {
            this.cordova.getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    // patch rit; 20.11.2019
                    // Bei Abbruch im Scanner Fenster wurde FATAL ERROR object null geworfen
                    if (mBarcodeView.getParent() != null) {
                        ((ViewGroup) mBarcodeView.getParent()).removeView(mBarcodeView);
                    }
                    cameraPreviewing = false;
                }
            });
        }

markusweb avatar Nov 27 '19 14:11 markusweb

Hi, Even I am facing the same issue. I tried updating the src file QRScanner.jave (i.e under the plugins folder Cordova-plugin-qrscanner ). However, it looks like it is not taking the modified one. Can you please tell me how to make changes in the plugin and use that while building APK for android in ionic framework 4.

Pradeepshivaram avatar Jan 12 '20 03:01 Pradeepshivaram

i have modified

/plugins/cordova-plugin-qrscanner/src/android/QRScanner.java

i then run

cordova build android
cordova run android --device

the build should take the QRScanner.java. just in case, check

/platforms/android/app/src/main/java/com/bitpay/cordova/qrscanner/QRScanner.java

i think this is the actual file for compiling the android app. as a last result just replace it (it is not the correct way of doing, but it should work)

markusweb avatar Feb 09 '20 13:02 markusweb