问题
So I'm having a lot of difficult with build.phonegap.com workflow. Using Cordova 3.3 and a Droid Razr Maxx. If I build locally, plugins work in emulator. In Phonegap build (on device), the javascript is working well but the plugins are totally borked. I have added the plugin code to my config.xml, but they don't show up in my project on build.phonegap.com. Using remote debugging, I have no navigator.device object, even after manually firing the deviceready callback with success. Therefore no calls to plugins work.
config.xml:
S,T,L. Something great. Marc
<gap:plugin name="org.apache.cordova.media-capture" />
<gap:plugin name="org.apache.cordova.device" />
<gap:plugin name="org.apache.cordova.file" />
<gap:plugin name="org.apache.cordova.file-transfer" />
<gap:plugin name="org.apache.cordova.geolocation" />
<gap:plugin name="org.apache.cordova.media" />
Some code, including my device ready:
// device APIs are available
//
function onDeviceReady() {
console.log('device ready');
$('#group1').hide();
$('.ui-btn').hide();
$('#group2').hide();
captureImage();
}
function checkboxHandler(callback) {
console.log(callback.id + " clicked, new value = " + callback.checked);
if (callback.checked) {
$('.' + callback.id).show();
console.log('showing ' + callback.id);
} else {
$('.' + callback.id).hide();
}
}
function addTemplateItems (template) {
// SNIP SNIP
}
$(document).ready(function() {
addTemplateItems(tagTemplate);
$(document).delegate('.ui-page', "swipeleft", function(){
var $nextPage = $(this).next('[data-role="page"]');
var $prevPage = $(this).prev('[data-role="page"]');
console.log("binding to swipe-left on "+$(this).attr('id') );
// swipe using id of next page if exists
if ($nextPage.length > 0) {
$.mobile.changePage($nextPage, { transition: 'slide' });
} else {
var message = 'tagged!';
// save tags here
flashNotify(message);
console.log('fire event!');
$('#flashNotification').promise().done(function () {
$('#group1').hide();
$('#group2').hide();
$('.ui-btn').hide();
addTemplateItems(tagTemplate);
$.mobile.changePage($prevPage, { transition: 'none' });
captureImage();
});
}
}).delegate('.ui-page', "swiperight", function(){
var $prevPage = $(this).prev('[data-role="page"]');
console.log("binding to swipe-left on "+$(this).attr('id') );
// swipe using id of next page if exists
if ($prevPage .length > 0) {
$.mobile.changePage($prevPage, { transition: 'slide', reverse : true });
} else {
alert('no backy backy!');
}
});
});
document.addEventListener("deviceready", onDeviceReady, false);
来源:https://stackoverflow.com/questions/21761618/plugins-not-working-in-phonegap-using-build-phonegap-com-no-navigator-device-ob