Phonegap BarcodeScanner plugin could work in Android project

可紊 提交于 2019-12-11 20:07:53

问题


I have tried to integrate the BarcodeScanner plugin to one of my Phonegap project of Android. I have even done all the thing step by step as the tutorial provided by github.

The library has been imported,BarcodeScanner.java file has been imported,

barcode.js has been imported,

activity has been added to AndroidManifest.xml

the config.xml in res path has been also modified.

When I test my app with eclipse, I have gotten the error below.

By the way, I have used phonegap 2.9 and my code for using the plugin is as below.

document.addEventListener("deviceready", deviceReady, true);

    function deviceReady() {
        var scanner = window.plugins.barcodeScanner;//note that cordova.plugins.barcodeScanner has also been tried. Same error.
        scanner.scan(
            function(result) {
                alert("We got a barcode\n" +
                    "Result: " + result.text + "\n" +
                    "Format: " + result.format + "\n" +
                    "Cancelled: " + result.cancelled);
            }, function(error) {
                alert("Scanning failed: " + error);
            });
    }

Really do not know what to do. Could you please give me any suggestion?

Thanks in advance.


回答1:


Finally, I work out it. It is because of Phonegap's version. The version should be above 3.0.



来源:https://stackoverflow.com/questions/19722668/phonegap-barcodescanner-plugin-could-work-in-android-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!