PhoneGap Build不包括Android或浏览器

时间:2017-03-03 18:53:44

标签: android cordova phonegap-build phonegap-desktop-app

通过官方的phonegap应用程序打开/加载时,我有一个可以正常运行的phonegap应用程序(执行ajax http请求等)。

但是当我上传并构建应用程序并从build.phonegap网站下载apk时,没有任何外部http请求有效。 我还注意到,因为我在Android上,在安装或服务请求(6.0+)上没有为应用程序请求任何权限,并且当在应用程序管理器中查看应用程序时,它被列为使用无权限。所以我假设没有互联网许可,我的应用程序不允许连接http请求。

所以我的问题是如何让它来请求我需要的互联网等权限?我认为phonegap应该默认请求像互联网和其他一些东西,但似乎它们根本没有被请求。

我还要注意,在应用程序中,平台文件夹中列出的唯一平台是浏览器,因此我没有平台 - > android-> config.xml来进行任何可能的编辑,正如我所见在这个网站的几个地方,但我的项目根config.xml看起来像这样,我的潜在敏感信息被*******' s取代。

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.******.mainapp" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
    <name>********</name>
    <description>
        **********
    </description>
    <author email="*******" href="********">
        ***********
    </author>
    <content src="index.html" />
    <access origin="http://*******.com/*" />
    <access origin="http://admin.*******.com/*" />
    <access origin="*" />
    <preference name="Orientation" value="portrait" />
</widget>

编辑:任何潜在的帮助,建议或建议都会有所帮助和赞赏,因为我一直试图解决这个问题一整天无济于事

EDIT2:应用中的示例请求

var http = new XMLHttpRequest();
var url = "http://www.********.com/functions/*******.php";
http.open("GET", url, true);
http.send();        
http.onreadystatechange = function() {
    if (http.readyState == 4) {
        if (http.responseText.indexOf("success") >= 0) {
            var data = http.responseText.split(" - ")[1];
            populate(data);
        } else {
            alert(http.responseText);
        }
        loadingScreen.style.display = "none";
    }
};

1 个答案:

答案 0 :(得分:0)

最初来自Kerri Shotts的回答解决了我的问题,

config.xml需要包含行

<plugin name="cordova-plugin-whitelist" source="npm" spec="~1.2.1" />

添加后,一切都按预期工作