2012-11-16 22 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