[英]Uncaught TypeError: Object #<Object> has no method 'exec' at file:///android_asset/www/index.html
[英]Application Error Is a directory (file:///#android_asset/www/index.html)
我正在使用phonegap在Android上開發一個應用程序,當我在手機上測試它時我得到這個錯誤Application Error Is a directory (file:///#android_asset/www/index.html)
我只有在我遇到此錯誤我的手機上沒有互聯網連接。
有什么建議?
這意味着,在index.html中,您使用的是需要訪問Internet的資源。 查看index.html並查找直接從Internet鏈接的任何CSS,javascript或Cordova文件。 如果是這樣,您必須下載相關文件並將其設置為本地文件。
當我直接鏈接我的Jquery移動JS文件時,我遇到了同樣的問題:
<script type="CSS/javascript" src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.js">
我做的是,下載了jquery.mobile-1.3.0.js文件並將其放在我的www文件夾中。 這解決了我的問題。
我在這里找到了答案: http : //dev.wavemaker.com/wiki/bin/wmdoc_6.5/PhoneGap?xpage=print#HTheconnectiontotheserverwasunsucessful28file3A2F2F2Fandroidasset2Fwww2Findexhtml29
6.1與服務器的連接不成功(file:///android_asset/www/index.html)
WHERE:在Android設備上啟動應用程序時。
您在index.html文件中放置任何請求遠程資源的內容都會導致Android設備拋出上述錯誤,然后您的應用程序將會死亡。 Weinre調試器是此錯誤的常見原因。
解決方案:將遠程資源的加載移出index.html並進入您的應用程序,在該應用程序中它將安靜地失敗。
你只需要將'index.html'重命名為'main.html',然后創建一個新的(虛擬)'index.html',只需要重定向到'main.html'
新'index.html'的內容:
<!doctype html>
<html>
<head>
<title>Title</title>
<script>
window.location='./main.html';
</script>
</head>
<body>
</body>
</html>
我找到了答案。
在<head>
標記內包含phonegap.js。 在構建期間,phonegap需要它。
<head>
<script src="phonegap.js"></script>
</head>
您無需下載phonegap.js。 您只需要包含所示的代碼。 在構建期間,phonegap將查找並自動包含它。 如果沒有,當您運行Native應用程序時,應用程序將在phonegap服務器上查找phonegap.js,這需要很長時間。 最終,您的應用程序加載將超時,並顯示您看到的錯誤消息。
哇! 我可以相信這一點。 我遇到了這個問題,我氣餒,幾乎放棄了使用phonegap。 但是,我在Phonegap的網站上看到了關於下面子標題下的phonegap.js的內容
https://build.phonegap.com/docs/app-overview
“確保你仍然可以訪問PhoneGap API”
“刪除phonegap.js后,您需要確保您的應用程序仍然可以訪問PhoneGap API。
為此,只需確保在index.html中進行以下引用“
<script src="phonegap.js"></script>
這就像魔術一樣。 有用。
大家歡呼。
空白訪問標記允許訪問所有外部資源。
<access origin="*" /> - a wildcard access tag allows access to all external resource.
否則,您可以指定特定域:
-->
<access origin="127.0.0.1*"/> <!-- allow local pages -->
<!--
<access origin="http://phonegap.com" /> - allow any secure requests to http://honegap.com/
<access origin="http://phonegap.com" subdomains="true" /> - same as above, but including subdomains, such as http://build.phonegap.com/
<access origin="http://phonegap.com" browserOnly="true" /> - only allows http://phonegap.com to be opened by the child browser.
-->
希望這可以幫助。
我遵循“ 快速開始的guie ”,我也有同樣的問題。 但我解決了。 我的問題是下載的phonegap和guie之間的不一致。
你必須確定這個細節: - 進入intex.html你鏈接正確的js腳本版本(例如:cordova-2.7.0.js) - 它必須匹配下載的phonegab版本。 phonegab版本和鏈接的js腳本必須匹配。
我希望這對你有幫助。
確保在頁面中包含了phonegap.js或cordova.js腳本。 這僅適用於您的移動設備。
你應該使用:
file:///android_asset/www/index.html
作為URL
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.