Android ReferenceError:未定义cordova

Android ReferenceError:未定义cordova,android,cordova,Android,Cordova,我得到以下例外 ReferenceError:未定义cordova 在cordova.addConstructor(函数()中) index.html <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="format-detection" content="telephone=no" /> <

我得到以下例外

ReferenceError:未定义cordova 在cordova.addConstructor(函数()中)

index.html

<!DOCTYPE html>

<html>
    <head>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />

     <!-- ionic css -->
        <link href="lib/ionic/css/ionic.css" rel="stylesheet">    
        <link rel="stylesheet" type="text/css" href="css/index.css" />
        <link rel="stylesheet" href="libs/leaflet/leaflet.css" />       
        <!--<link rel="stylesheet" href="libs/leaflet/leaflet-routing-machine.css" />-->
        <!--[if lte IE 8]>
                <link rel="stylesheet" href="libs/leaflet/leaflet.ie.css" />
        <![endif]-->
        <!-- ionic/angularjs scripts -->


        <title>"Test App"</title>    
        <script type="text/javascript" src="cordova.js"></script>

    </head>

    <body ng-app="starter" animation="slide-left-right-ios7">

    <!-- 
      The nav bar that will be updated as we navigate between views
      Additional attributes set its look, ion-nav-bar animation and icons
      Icons provided by Ionicons: http://ionicons.com/ 
    -->

    <!-- 
      The views will be rendered in the <ion-nav-view> directive below
      Templates are in the /templates folder (but you could also
      have templates inline in this html file if you'd like).
    -->

       <ion-nav-view></ion-nav-view> 
       <div id="time"></div> 

   <input type="hidden" value="" id="currentLatitude"/>
    <input type="hidden" value="" id="currentLongitude"/>


        <script type="text/javascript" src="cordova.js"></script>



        <script src="lib/ionic/js/ionic.bundle.js"></script>
        <!--<script type="text/javascript" src="js/jquery-2.0.3.min.js"></script>-->
        <script src="libs/leaflet/leaflet.js"></script>
        <!--<script type="text/javascript" src="js/core.js"></script>-->     
        <script src="libs/leaflet/angular-leaflet-directive.min.js"></script>        
        <!--<script src="libs/leaflet/leaflet-routing-machine.min.js"></script>-->
        <!-- cordova script (this will be a 404 during development) -->

        <!-- your app's script -->

        <script src="js/app.js"></script>  
        <script src="js/controllers.js"></script>
       <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyAEWnOhu5ePxhmZ1Cx7ZgcamoRvN88mw2Y&sensor=true"></script>


       <script type="text/javascript" src="js/samplePlugin.js"></script>
        <script type="text/javascript">
document.addEventListener('deviceready', function()
    {
    alert("HI1")
        window.plugins.SamplePlugin.getTime
        (
            function(result)
            {
            alert("HI2")
                displayTime(result)
            },
            function(error)
            {
                console.log(error)
            }
        );
    }, true
);

function displayTime(result)
{
    document.getElementById("time").innerHTML = result.time;
}

</script>

</body>
</html>
我遵循了这个教程


在htmldup的head部分包含phonegap.js/cordova.js?检查编辑的问题-我已经在head部分添加了它,但仍然有相同的例外我认为问题是cordova和phonegap需要构建项目才能生成
cordova.js
。该文件在此之前不存在。
var SamplePlugin = function()
{
};

SamplePlugin.prototype.getTime = function(successCallback, failureCallback)
{
    return cordova.exec(
            successCallback,        //Function called upon success
            failureCallback,        //Function called upon error
            'ExamplePlugin',        //Tell PhoneGap to run "ExamplePlugin" Plugin
            'getTime',                //Tell the which action we want to perform, matches an "action" string
            []);                    //A list of args passed to the plugin, in this case empty
};

cordova.addConstructor(function()
{
    cordova.addPlugin("SamplePlugin", new SamplePlugin());
});