Phonegap-plugin-barcodescanner: Android cannot locate methods in Intents

Created on 19 Jul 2017  路  5Comments  路  Source: phonegap/phonegap-plugin-barcodescanner

Expected Behaviour

Android to build successfully

Actual Behaviour

Getting these errors:

BarcodeScanner.java:178: error: cannot find symbol
intentScan.putExtra(Intents.Scan.SHOW_FLIP_CAMERA_BUTTON, obj.optBoolean(SHOW_FLIP_CAMERA_BUTTON, false));
^
symbol: variable SHOW_FLIP_CAMERA_BUTTON
location: class Scan

BarcodeScanner.java:179: error: cannot find symbol
intentScan.putExtra(Intents.Scan.SHOW_TORCH_BUTTON, obj.optBoolean(SHOW_TORCH_BUTTON, false));
^
symbol: variable SHOW_TORCH_BUTTON
location: class Scan

BarcodeScanner.java:180: error: cannot find symbol
intentScan.putExtra(Intents.Scan.TORCH_ON, obj.optBoolean(TORCH_ON, false));
^
symbol: variable TORCH_ON
location: class Scan

BarcodeScanner.java:181: error: cannot find symbol
intentScan.putExtra(Intents.Scan.SAVE_HISTORY, obj.optBoolean(SAVE_HISTORY, false));
^
symbol: variable SAVE_HISTORY
location: class Scan

BarcodeScanner.java:183: error: cannot find symbol
intentScan.putExtra(Intents.Scan.RESULT_DISPLAY_DURATION_MS, "" + obj.optLong(RESULTDISPLAY_DURATION));
^
symbol: variable RESULT_DISPLAY_DURATION_MS
location: class Scan

BarcodeScanner.java:192: error: cannot find symbol
intentScan.putExtra(Intents.Scan.ORIENTATION_LOCK, obj.optString(ORIENTATION));
^
symbol: variable ORIENTATION_LOCK
location: class Scan

BarcodeScanner.java:254: error: cannot find symbol
intentEncode.setAction(Intents.Encode.ACTION);
^
symbol: variable Encode
location: class Intents

BarcodeScanner.java:255: error: cannot find symbol
intentEncode.putExtra(Intents.Encode.TYPE, type);
^
symbol: variable Encode
location: class Intents

BarcodeScanner.java:256: error: cannot find symbol
intentEncode.putExtra(Intents.Encode.DATA, data);

cordova --version 6.0.4
cordova platforms Android

Attempting to build in Android Studio 2.2.3

Plugin version

phonegap-plugin-barcodescanner 6.0.8
android can't reproduce

Most helpful comment

I managed to fix it. For me this was the issue:
I had the "Cordova QR Scanner" plugin installed as well (https://github.com/bitpay/cordova-plugin-qrscanner), along with this plugin.

Apparently, both plugins don't work side by side. Removing the "cordova-plugin-qrscanner" plugin did the trick for me. I can now build it for Android without errors.

I hope this helps.

All 5 comments

Exact same error here. Does anyone have a solution?

@justinhenricks builds fine for me from the CLI and AndroidStudio. For some reason in your setup the .aar for ZXing is not being imported into the project which is why you get the above errors. When you open the project in AndroidStudio do you do File->New-Import Project and select the $Project_name/platforms/android directory?

I managed to fix it. For me this was the issue:
I had the "Cordova QR Scanner" plugin installed as well (https://github.com/bitpay/cordova-plugin-qrscanner), along with this plugin.

Apparently, both plugins don't work side by side. Removing the "cordova-plugin-qrscanner" plugin did the trick for me. I can now build it for Android without errors.

I hope this helps.

This actually ended up being our exact situation as well. QR Scanner and Barcode Scanner cannot be installed at the same time! Good to know, consider this closed. Thanks!

This thread has been automatically locked.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bajranghudda1 picture Bajranghudda1  路  4Comments

thomas-tran picture thomas-tran  路  9Comments

camilonos77 picture camilonos77  路  7Comments

McOffsky picture McOffsky  路  7Comments

JackRo picture JackRo  路  6Comments