在Android设备上使用Ionic部署

3

Ionic版本:1.5.5

Cordova版本:5.0.0

Ionic部署:0.1.6

我按照这里显示的所有说明进行了操作。

之后,运行:

ionic build android && ionic run android

后来,对index.html文件进行了小的编辑并运行。
ionic upload

根据日志,我发现一些被标记为IONIC_DEPLOY_DOWNLOAD的文件下载,一旦提取完成,就会弹出这个错误。

06-18 16:47:47.771: D/SystemWebViewClient(7128):
CordovaWebViewClient.onReceivedError: Error code=-1
Description=net::ERR_FILE_NOT_FOUND 
URL=file:///data/data/com.org.app/app_eddaae501776ab76c86f69073/index.html



06-18 16:47:47.921: I/chromium(7128): 
[INFO:CONSOLE(0)] "Not allowed to load local resource:
file:///android_asset/webkit/android-weberror.png", 
source: data:text/html,chromewebdata (0)

enter image description here

编辑

添加日志错误

enter image description here


1
你是否已经安装并配置了这个插件:https://github.com/apache/cordova-plugin-whitelist? - Mark Veenstra
很好的发现!它似乎在iOS上运行正常,唯一的问题是Android。我已经按照这里建议的添加了<access origin="**" />标签到config.xml中:https://cordova.apache.org/docs/en/4.0.0/guide_appdev_whitelist_index.md.html#android-whitelisting我把它放在了<platform>标签内:<platform name="android"> <allow-navigation href="" /> <access origin="" /> </platform> 我错过了什么吗? - Roberto von Schoettler
还要在index.HTML中设置此标签:https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy - Mark Veenstra
即使我在编辑测试的index.html文件时没有添加<meta http-equiv="Content-Security-Policy" content="default-src *">,最后一个操作是由IONIC_DEPLOY_REDIRECT完成的,显示的错误是:06-19 14:02:42.908: D/CordovaWebViewImpl(5785): onPageDidNavigate(file:///data/data/com.org.app/app_eddaae501776ab76c86f69073/index.html) - Roberto von Schoettler
2个回答

3

我遇到了同样的问题。

在 Android 更新期间,尝试创建一个已经存在的目录会生成内部错误。

GIT 中有一个分支可以解决这个问题。(https://github.com/eweap/ionic-plugins-deploy)。

要使其工作,请执行以下命令:

$ Cord plug rm com.ionic.deploy
$ Cord plugin add https://github.com/eweap/ionic-plugins-deploy
$ Ionic platform removes android
$ Ionic platform add android
$ Ionic run android

完成!


0

将此添加到您的config.xml文件中

<allow-navigation href="file://*/*"/>

不使用live server运行

使用:

ionic emulate android

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接