0

cordova 发生了一件奇怪的事情,即使是最简单的代码也不再适用。代码工作得很好,但从昨天开始就不行了。我没有更改 manifest.xml 或任何其他文件中的任何内容。是我的设备吗?

<title>Device Properties Example</title>

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">

    // Wait for Cordova to load
    //
    function onload(){
        document.addEventListener("deviceready", onDeviceReady, false);
    }
    // Cordova is ready
    //
    function onDeviceReady() {
        alert('test')
        var element = document.getElementById('deviceProperties');
         console.log('test');
        element.innerHTML = 'Device Name: '     + device.name     + '<br />' +
                'Device Cordova: '  + device.cordova + '<br />' +
                'Device Platform: ' + device.platform + '<br />' +
                'Device UUID: '     + device.uuid     + '<br />' +
                'Device Model: '    + device.model     + '<br />' +
                'Device Version: '  + device.version  + '<br />';
    }

</script>

现在我不能再运行cordova了。这就是我得到的logcat

05-15 11:46:33.478:I/CordovaLog(26092):将日志级别更改为 DEBUG(3)
05-15 11:46:33.478: I/CordovaLog(26092): 找到 useBrowserHistory=true 的偏好
05-15 11:46:33.478: D/CordovaLog(26092): 找到 useBrowserHistory=true 的偏好
05-15 11:46:33.478: I/CordovaLog(26092): 找到退出挂起=假的偏好
05-15 11:46:33.478: D/CordovaLog(26092): 找到退出时暂停 = 假的偏好
05-15 11:46:33.483:I/CordovaLog(26092):找到 loadingDialog=MORE 的首选项,正在加载...
05-15 11:46:33.483: D/CordovaLog(26092): 找到 loadingDialog=MORE 的首选项,正在加载...
05-15 11:46:33.503: D/JsMessageQueue(26092): 设置 native->JS 模式为 2
05-15 11:46:33.508: D/DroidGap(26092): DroidGap.init()
05-15 11:46:33.618: D/CordovaWebView(26092): >>> loadUrl(file:///android_asset/www/index.html)
05-15 11:46:33.618:D/PluginManager(26092):init()
05-15 11:46:33.623: D/CordovaWebView(26092): >>> loadUrlNow()
05-15 11:46:33.628: D/DroidGap(26092): 恢复应用
05-15 11:46:33.688: D/SoftKeyboardDetect(26092): 忽略此事件
05-15 11:46:33.698: D/DroidGap(26092): onMessage(onPageStarted,file:///android_asset/www/index.html)
05-15 11:46:34.088:D/SoftKeyboardDetect(26092):忽略此事件
05-15 11:46:36.068: D/Cordova(26092): onPageFinished(file:///android_asset/www/index.html)
05-15 11:46:36.068: D/DroidGap(26092): onMessage(onNativeReady,null)
05-15 11:46:36.068: D/DroidGap(26092): onMessage(onPageFinished,file:///android_asset/www/index.html)
05-15 11:46:38.068:D/DroidGap(26092):onMessage(微调器,停止)
05-15 11:46:38.353: W/dalvikvm(26092): disableGcForExternalAlloc: false

怎么了?

4

1 回答 1

0

The phonegap plugins: camera, accelerator etc. works but the geolocation not. This is the code all permissions are installed like before:

<title>Device Properties Example</title>

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">

    // Wait for Cordova to load
    //
    document.addEventListener("deviceready", onDeviceReady, false);

    // Cordova is ready
    //
    function onDeviceReady() {
        console.log('test');
        alert('test');
        navigator.geolocation.getCurrentPosition(onSuccess, onError);
    }

    // onSuccess Geolocation
    //
    function onSuccess(position) {
        var element = document.getElementById('geolocation');
        console.log(position.coords.latitude);
        element.innerHTML =
                'Latitude: '           + position.coords.latitude              + '<br />' +
                'Longitude: '          + position.coords.longitude             + '<br />' +
                'Altitude: '           + position.coords.altitude              + '<br />' +
                'Accuracy: '           + position.coords.accuracy              + '<br />' +
                'Altitude Accuracy: '  + position.coords.altitudeAccuracy      + '<br />' +
                'Heading: '            + position.coords.heading               + '<br />' +
                'Speed: '              + position.coords.speed                 + '<br />' +
                'Timestamp: '          +                                   position.timestamp          + '<br />';
    }

    // onError Callback receives a PositionError object
    //
    function onError(error) {
        alert('code: '    + error.code    + '\n' +
                'message: ' + error.message + '\n');
    }

</script>

But the variable "position" isn't set or something, this plugin was working before now it ain't. :(

于 2013-05-15T11:20:43.653 回答