Phonegap无法在Android模拟器中运行

Mic*_*hel 6 android cordova

我按照基本的Phonegap教程(Eclipse,Android SDK,ADT Phonegap)中的所有步骤,在assets/www文件夹中创建了一个HMTL页面,运行它,它显示了我的hello world html.

第2步:我在HTML页面的CDN上添加了对jQuery Mobile的引用:它工作正常.

第3步:我创建了一个新的html页面,复制粘贴下面的代码,这是来自Phonegap网站的一个示例,它确实......没有.甚至没有警报(我添加了一些警报,看看是否有事情发生,但即使是onDeviceReady事件也不会触发.

我有Phonegap JAR,cordova-1.7.0.js在我的assest/www目录中,但可能缺少一些东西.

有人可以帮我吗?

我还尝试了Phonegap网站上的另一个样本('设备属性'样本),但它仍然无效.

这是一个全新的Eclipse安装,我将Android版本设置为2.3.3,我使用的是Phonegap 1.7.0.

================

编辑

我尝试了一些,现在我可以重现错误,但不知道为什么会发生.

所以我使用Phonegap示例项目创建了一个新项目,它可以工作.

所以,我将该项目中的所有资产(1个html,2个js和1个css)复制到我的项目中,让应用程序从该html开始(从我的活动类开始),并且它可以工作.

现在为了有趣的部分(不是):我将startpage重置为我的'old'sindex.html(这是jQuery mobile),然后点击示例html的链接,它不起作用.

所以示例html作为启动:它工作,通过链接打开示例html:不起作用.

当我加载其他不起作为起始页面的html页面,而不是通过起始页面打开它们时,它们也起作用.

那么,我的jQuery Mobile支持的索引页面是否可能导致问题呢?(我将复制粘贴下面的代码).

EDIT2:当我使用非jQuery Mobile索引页面并<A href>链接到示例html 的普通链接时,它也可以.所以我越来越暗示我认为jQuery mobile在我的方式......

链接代码是这样的:

<li><a href="index4.html" data-transition="none">phonegap example</a></li>
Run Code Online (Sandbox Code Playgroud)

jQuery Mobile主页:

<html>
<head>
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
    <link rel="stylesheet" href="http://www.verfrisser.net/kalender/mobile/verfrisser.css" />
    <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"></script>
</head>
<body>
  <div data-role="page">

    <div data-role="header">
        <h1>De NerdNight kalender</h1>
        <a href="about.html" data-rel="dialog">About</a><a href="genereren.html" data-transition="pop">Genereren</a>
    </div><!-- /header -->

    <div data-role="content">
        <img id="verfrisserlogo" src="verfrisserlogo.png" />
        <ul data-role="listview" data-inset="true" data-filter="false">
            <li><a href="2011.html" data-transition="none">2011</a></li>
            <li><a href="2012.html" data-transition="none">2012</a></li>
            <li><a href="2013.html" data-transition="none">2013</a></li>
            <li><a href="testing.html" data-transition="none">testing</a></li>
            <li><a href="testing2.html" data-transition="none">testing2</a></li>
            <li><a href="testing3.html" data-transition="none">testing3</a></li>
            <li><a href="index4.html" data-transition="none">phonegap example</a></li>
        </ul>
    </div><!-- /content -->

    <div data-role="footer">
        <h6>(C) Verfrisser 1998 till now</h6>
    </div><!-- /footer -->
</div><!-- /page -->
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

================

示例HTML(仅显示文本'A对话框将在页面中报告网络状态')

<!DOCTYPE html>
<html>  
<head>    
    <title>navigator.network.connection.type Example</title>    
    <script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"></script> 
 <script type="text/javascript" charset="utf-8">    
   // Wait for Cordova to load    //    
   document.addEventListener("deviceready", onDeviceReady, false);  
   // Cordova is loaded and it is now safe to make calls Cordova methods   
    alert ('stand alone');
   //    
   function onDeviceReady() {
    alert ('onDeviceReady'); 
   checkConnection();   
   }    
   function checkConnection() {        
   var networkState = navigator.network.connection.type;        
   var states = {};       
   states[Connection.UNKNOWN]  = 'Unknown connection';        
   states[Connection.ETHERNET] = 'Ethernet connection';        
   states[Connection.WIFI]     = 'WiFi connection';       
   states[Connection.CELL_2G]  = 'Cell 2G connection';   
   states[Connection.CELL_3G]  = 'Cell 3G connection';   
   states[Connection.CELL_4G]  = 'Cell 4G connection';   
   states[Connection.NONE]     = 'No network connection';
   alert('Connection type: ' + states[networkState]); 
   }  

</script> 
</head>  
<body>
    <p>A dialog box will report the network state.</p>  
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

dha*_*val 9

使用默认行为时,下一页将作为DOM元素加载,因此deviceready不会再次调用javascript .

尝试使用以下方法之一以正常方式运行它:

<li><a href="testing2.html" data-transition="none" rel="external">testing2</a></li>
Run Code Online (Sandbox Code Playgroud)

要么

<li><a href="testing2.html" data-transition="none" data-ajax="false">testing2</a></li>
Run Code Online (Sandbox Code Playgroud)

说明:

单击链接时,jQuery mobile将确保链接引用本地URL,如果是,则会阻止链接的默认单击行为发生,并通过Ajax请求引用的URL.当页面成功返回时,它会将location.hash设置为新页面的相对URL.

如果Ajax请求成功,则将新页面内容添加到DOM,所有移动窗口小部件都自动初始化,然后将新页面设置为带有页面转换的视图.

有关更多详细信息,请查看文档