【发布时间】:2015-01-29 18:36:29
【问题描述】:
所以大约 3 年前,我玩了一点 PhoneGap。我正在编写基本的 html 和 javascript 并推送到 github 存储库。然后,PhoneGap Build 将从该存储库中提取并为我构建一个可以安装到手机上的 APK。
快进三年,引入了节点以使过程更加流畅。
除了我修改了 hello world 应用程序以包含一个用于执行条形码扫描的按钮:
phonegap plugin add com.phonegap.plugins.barcodescanner
然后尝试通过添加一个按钮作为 onclick 事件(添加到预先存在的应用程序对象)来使用条形码扫描器:
buttonPressed: function() {
alert("Clicked");
cordova.plugins.barcodeScanner.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);
}
);
}
如果我在我的 Android 手机上使用 phonegap 开发者应用程序,我会收到第一个警报,但没有别的。如果我使用 phonegap build 来获取 APK,我会在 Jasmine 中得到一堆失败的规范,例如
cordova.require object should exist BarcodeScanner plugin should exist.
module cordova/plugin/BarcodeScanner not found
cordova.require object should exist should contain a scan function.
cordova.require object should exist should contain an encode function.
cordova.require object should exist should contain three DestinationType constants.
我没有在本地开发中添加任何平台,因为我并没有真正计划在那里进行构建。另外,我在 Linux 上,所以即使我想添加 iOS 平台也无法添加。
谁能告诉我我做错了什么?
【问题讨论】:
标签: linux cordova phonegap-plugins phonegap-build