2012-11-16 24 views
0

我问这个了很多天前,我觉得这是现在去排队,所以我张贴这一次,请告诉我,任何一个能帮助我PhoneGap的错误的PhoneGap +本地

ERROR the connection to the server was unsuccessful. (file ///android_asset/www/index.html) pure phonegap app 

代码如下:

<html> 
<head> 
<link rel="stylesheet" href="jquery-mobile/jquery.mobile.css"> 
<link rel="stylesheet" href="jquery-mobile/jqm-docs.css"> 
<script src="jquery-mobile/jquery.js"></script> 
<script> 
$(document).bind("mobileinit", function(){ 
    $.mobile.loadingMessageTextVisible = true; 
}); 
</script> 
<script src="jquery-mobile/jquery_mobile_old.js"></script> 
<script> 
    $(document).on("click", ".show-page-loading-msg", function() { 
     var $this = $(this), 
      theme = $this.jqmData("theme") || $.mobile.loadingMessageTheme, 
      msgText = $this.jqmData("msgtext") || $.mobile.loadingMessage, 
      textonly = !!$this.jqmData("textonly"); 
     $.mobile.showPageLoadingMsg(theme, msgText, textonly); 
    }) 
    .on("click", ".hide-page-loading-msg", function() { 
     $.mobile.hidePageLoadingMsg(); 
    }); 
</script> 

</head> 
<body> 
<div data-role="header"><h1>My App</h1></div> 

<a href="http://xyz.php" style="text-decoration:none"> 
<button class="show-page-loading-msg">xyz</button> 
</a> <a href="http://xyz.php" style="text-decoration:none"> 
<button class="show-page-loading-msg">xyz</button> 
</a> <a href="http://xyz.php" style="text-decoration:none"> 
<button class="show-page-loading-msg">xyz</button> 
</a> <a href="http://xyz.php" style="text-decoration:none"> 
<button class="show-page-loading-msg">xyz</button> 
</a> <a href="http://xyz.php" style="text-decoration:none"> 
<button class="show-page-loading-msg">xyz</button> 
</a> <a href="http://xyz.php" style="text-decoration:none"> 
<button class="show-page-loading-msg">xyz</button> 
</a> <a href="http://xyz.php" style="text-decoration:none"> 
<button class="show-page-loading-msg">xyz</button> 
</a> <a href="#" style="text-decoration:none"> 
<button class="show-page-loading-msg">Outstanding Analysis For Creditors</button> 
</a> 

但它是在浏览器中正常使用。

问题是,当我试图在手机打开这个它给error.I正在使用Dreamweaver CS6和使用build.phonegap.com建设时,它https://build.phonegap.com/

回答

0

,你必须访问.java文件,其中包含加载页面的活动。如果是,则最有可能检查路径,网页的网址不正确。

也是正确的html文件的名称,如错误消息中所示。

你看过page中的文档吗?请记住,文件名是index.html而不是index.htm或任何其他东西。

更新: 我试图把phonegap.js的代码放到一个单独的文件,但不包括参考phonegap.js,应用程序无法正常工作。所以看起来,在index.html文件中包含对phonegap.js的引用很重要。

<html> 
<head> 
<meta name="viewport" content="user-scalable=no, initial-scale=3, maximum-scale=3, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=high-dpi" /> 
     <link rel="stylesheet" type="text/css" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.css" /> 

     <script type="text/javascript" charset="utf-8" src="http://code.jquery.com/jquery-1.8.2.min.js"></script> 
     <script type="text/javascript" charset="utf-8" src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.js"></script> 
     <script src="phonegap.js"></script> 
<script> 
$(document).bind("mobileinit", function(){ 
    $.mobile.loadingMessageTextVisible = true; 
}); 
</script> 
<script src="jquery-mobile/jquery_mobile_old.js"></script> 
<script> 
    $(document).on("click", ".show-page-loading-msg", function() { 
     var $this = $(this), 
      theme = $this.jqmData("theme") || $.mobile.loadingMessageTheme, 
      msgText = $this.jqmData("msgtext") || $.mobile.loadingMessage, 
      textonly = !!$this.jqmData("textonly"); 
     $.mobile.showPageLoadingMsg(theme, msgText, textonly); 
    }) 
    .on("click", ".hide-page-loading-msg", function() { 
     $.mobile.hidePageLoadingMsg(); 
    }); 
</script> 

</head> 
<body> 
<div data-role="header"><h1>My App</h1></div> 

<a href="http://xyz.php" style="text-decoration:none"> 
<button class="show-page-loading-msg">xyz</button> 
</a> <a href="http://xyz.php" style="text-decoration:none"> 
<button class="show-page-loading-msg">xyz</button> 
</a> <a href="http://xyz.php" style="text-decoration:none"> 
<button class="show-page-loading-msg">xyz</button> 
</a> <a href="http://xyz.php" style="text-decoration:none"> 
<button class="show-page-loading-msg">xyz</button> 
</a> <a href="http://xyz.php" style="text-decoration:none"> 
<button class="show-page-loading-msg">xyz</button> 
</a> <a href="http://xyz.php" style="text-decoration:none"> 
<button class="show-page-loading-msg">xyz</button> 
</a> <a href="http://xyz.php" style="text-decoration:none"> 
<button class="show-page-loading-msg">xyz</button> 
</a> <a href="#" style="text-decoration:none"> 
<button class="show-page-loading-msg">Outstanding Analysis For Creditors</button> 
</a> 
+0

这是我的index.html页面,我没有使用任何.java文件。 – user1635431

+0

我以前从未使用过build.phonegap.com。但出于好奇,我看了一下。它似乎是使用该应用程序的唯一问题是,如果通过zip文件或使用存储库上传的代码是,如果文件夹结构不正确。 – Dilberted

+0

文件夹结构是否可以,如果在此页面中输入'你好'并删除所有js文件,那么页面正在正常加载到手机中。 – user1635431