未捕获到的TypeError:无法读取Phonegap上未定义的属性“诊断”

时间:2018-10-04 20:41:55

标签: cordova-plugins phonegap-plugins phonegap

在我的Phonegap项目中,诊断插件给出以下错误!

未捕获的TypeError:无法读取未定义的属性“诊断”

我已经验证了版本,卸载并安装了插件。而且这种情况经常发生,我什至与其他插件隔绝了!

    var structureApp = {

    initialize: function(){
        this.bindEvents();
    },
    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
        document.addEventListener("deviceRegistered", this.successDeviceRegistered, false);
    },
    onDeviceReady: function() {
        structureApp.mount();
        navigator.geolocation.getCurrentPosition(
            structureApp.geoLocate,
            structureApp.geoErro,
            {enableHighAccuracy:true, maximumAge:30000, timeout:27000}
        );
        .structureApp.getPosition();
    },
    mount: function() {

        structureApp.logoutNotification();

    },
    geoLocate: function(position){
        var lat=position.coords.latitude;
        var lon=position.coords.longitude;
        localStorage.setItem('lat',lat);
        localStorage.setItem('lon',lon);


        $("#latitude").html("Sua Latidute:" + lat);
        $("#longitude").html("Sua Longitude:" + lon);
    },
    geoErro: function (e){
        alert("Houve um erro:" + e.message);
    },
    getPosition: function (){

         cordova.plugins.diagnostic.isLocationAuthorized(function(enabled){
            if(!enabled){
                 navigator.diagnostic.requestLocationAuthorization(function(status){
                    navigator.geolocation.getCurrentPosition(function(position){
                    alert(position.coords.latitude, position.coords.longitude);
                    startSplash();
                }, function(error){
                    alert("Something went wrong while retrieving your position. " + error.message);
                },
                {
                   maximumAge:6000,
                   timeout:5000,
                   enableHighAccuracy: true
                });

                 },function(error){
                    alert(error.message);
                });
            }
        },function(error){
            alert("The following error occurred: " + error.message);
        });

    }


};
$(function(){ structureApp.initialize(); });

我的config.xml看起来像这样:

    <?xml version='1.0' encoding='utf-8'?>
<widget id="com.phonegap.meuapp" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
    <name>MeuAPP</name>
    <description>
        ######
    </description>
    <author email="" href="">
        ########
    </author>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <allow-navigation href="*" />
    <preference name="orientation" value="default" />
    <preference name="phonegap-version" value="cli-6.5.0" />
    <preference name="android-build-tool" value="ant|gradle" />
    <preference name="android-minSdkVersion" value="10" />
    <preference name="android-maxSdkVersion" value="24" />
    <preference name="android-targetSdkVersion" value="12" />

    <preference name="android-windowSoftInputMode" value="stateVisible|adjustResize" />
    <platform name="android">
        <config-file parent="/*" target="AndroidManifest.xml">
            <uses-permission android:name="android.permission.BLUETOOTH" />
            <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
            <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
            <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
            <uses-permission android:name="android.permission.RECORD_AUDIO" />
            <uses-permission android:name="android.permission.CAMERA" />
            <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
            <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
            <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
            <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
            <uses-permission android:name="android.permission.READ_CONTACTS" />
            <uses-permission android:name="android.permission.READ_CALENDAR" />
        </config-file>
    </platform>
    <platform name="ios">
        <plugin name="cordova-plugin-background-fetch" spec="*" />
        <config-file parent="UIBackgroundModes" platform="ios" target="*-Info.plist">
            <array>
                <string>fetch</string>
                <string>remote-notification</string>
            </array>
        </config-file>
    </platform>
    <platform name="windows">
        <preference name="windows-target-version" value="10.0" />
        <preference name="target-device" value="universal" />
        <preference name="Windows.Universal-MinVersion" value="10.0.0.0" />
    </platform>
    <engine name="ios" spec="~4.5.5" />
    <engine name="windows" spec="latest" />
    <engine name="android" spec="^7.0.0" />
    <plugin name="cordova-plugin-dialogs" spec="~2.0.1" />
    <plugin name="cordova-plugin-file-transfer" spec="~1.7.1" />
    <plugin name="cordova-plugin-geolocation" spec="~4.0.1" />
    <plugin name="cordova-plugin-request-location-accuracy" spec="^2.2.3" />
    <plugin name="cordova-android-support-gradle-release" spec="^1.4.4">
        <variable name="ANDROID_SUPPORT_VERSION" value="25.+" />
    </plugin>
    <plugin name="cordova.plugins.diagnostic" spec="^4.0.10" />
</widget>

有人可以帮我吗?

0 个答案:

没有答案