繁体   English   中英

应用程序错误是一个目录(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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM