Worklight 6.1 - Barcode Scanner Plugin

2019-09-26 09:29发布

I'm followed this IBM Worklight article instructions - link.

On Eclipse - when I try to run BarcodeScannerSampleBarcodeScannerSampleAppAndroid - I get message box with title - "Android Launch", that says:"Your projects contains error".

At Markers window I get this Error:

The container 'Android Dependencies' references non existing library 
'D:\Users\MyUser\workspaceNew\CaptureActivity\bin\captureactivity.jar'
BarcodeScannerSampleBarcodeScannerSampleAppAndroid
Build path
Build Path Problem

Directory - "D:\Users\MyUser\workspaceNew\CaptureActivity\bin\" doesn't contains "captureactivity.jar" file.

Any idea? Thanks!

3条回答
萌系小妹纸
2楼-- · 2019-09-26 09:35

Looks like you missed one step.

- First we need to import the Java facade to the plugin. This is the code that implements the 
  mandatory CordovaPlugin class and the exec() method. In the Worklight project, go to the 
  location for the Java code
  BarcodeScannerSample/apps/BarcodeScannerSampleApp/android/native/src 
- Right-click on the src folder and select Import...> File System
- Select the directory
  <GIT CLONE FOLDER>/BarcodeScanner/src/android 
  Select File > Import, of type File System, the contents of the com folder from the same 
  source folder
  <GIT CLONE FOLDER>/BarcodeScanner/src/android 
  You should be able see that the com.phonegap.plugins.barcodescanner.BarcodeScanner.java 
  file has beenimported into the src folder.

And make sure you configured the config.xml and AndroidManifest.xml properly.

You can find the file here: https://github.com/phonegap-build/BarcodeScanner/

查看更多
Melony?
3楼-- · 2019-09-26 09:39

Make sure you follow the instructions in the blog post to the letter.
It sounds like you did not follow the last step, which says to:

  1. Right-click the generated Android project and select Properties
  2. In the Android entry from the left pane, click on Add and select CaptureActivity

Fuller steps:

  1. Download & extract the zip from GitHub: https://github.com/phonegap-build/BarcodeScanner/archive/master.zip
  2. In Eclipse, File > Import > Android > Existing Android Code Into Workspace
  3. Click on Browse and then find the extracted folder
  4. Navigate in it into ../BarcodeScanner-master/src/android/LibraryProject and click Finish

Then you need to continue with creating the Worklight project. It's two different projects.

  1. In your Worklight project, you need to navigate to your-project\apps\your-app\android\native
  2. There you need to right-click on the src folder and select Import... > General > File System
  3. Navigate to the same extracted folder, into ../BarcodeScanner-master/src/android and click Next
  4. Tick the checkbox next to the android option that will appear after step 3

Next you need to configure AndroidManifest.xml and config.xml in the same location (your-app\android\native).

In both the CaptureActivity AndroidManifest.xml and the Worklight project AndroidManifest.xml I've set the minSdkVersion to 19, which I have installed.

Now,

  1. Once you're done with that, build the project.
  2. Right-click on the generated Android project > Properties > Android
  3. Click the Add... button and select the CaptureActivity library

Make sure to not select the "Is library" checkbox.

查看更多
Lonely孤独者°
4楼-- · 2019-09-26 09:45

Yaniv thanks.

The problem was in CaptureActivity library.
After importing "Existing Android Code Into Workspace", I should BUILD the project library.
Then it create a directory - "D:\Users\MyUser\workspaceNew\CaptureActivity\bin\" with "captureactivity.jar" file in it.

Thanks!

查看更多
登录 后发表回答