简体   繁体   中英

Phonegap plugin: BarcodeScanner causing errors in Eclipse

I am a student, new at phonegap mobile app development. I am trying to install the BarcodeScanner plugin following this guide . The guide mentioned installing 3 plugins, BarcodeScanner , Dialogs and Inappbrowser.

Here is the problem:

Eclipse found 'red cross' errors in 'Main activity' after the barcode scanner plugin is installed. ( Eclipse with dialog , Eclipse with both ). When I attempt to organize the import files in Eclipse using 'shift+ctrl+O', they returned:

/src/com/phonegap/plugins/barcodescanner/Barcodescanner.java contains ambiguous reference. User interaction is required

'Problems view' in Eclipse when selected the com.phonegap.plugin.barcodescanner under the SRC file displays:

Intents cannot be resolved to a variable 

^error found on on every 'intent' in the .java file

The import com.google cannot be resolved

^error found on below:

import com.google.zxing.client.android.Intents;

In addition, the barcode scanner plugin has created additional files that the dialog plugin previously did not. 之前 后

The root directory I have installed the plugins on was in the folder 'hello', which has the config.xml file.

Question: Why is the barcode scanner plugin being difficult? It seems like it is a directory problem but I have installed dialog plugin the same way and it is not producing error. Is it possible that the barcodescanner plugin i installed from cordova using the cmd is not working properly? What should I do to get the plugin working? Thanks !

Looks like you didnt successfully import zxing intent.java. "Intents" is a variable that is declared in one of the java found in zxing src folders, hence variable will not be resolved.

What you need to do is to download zxing from github and copy com.google.zxing.client.android over to your current project src folder.

So, make sure in your project src file, there is another package named "com.google.zxing.client.android" and it consists of this "intents.java"

The extra folder isnt an issue because it consists of the gradle of the barcode scanner plugin you installed, which is normal. You can search more about "gradles" in google, used by android studio.

Cheers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM