首页 > 解决方案 > Android 9 Pie 上的 phonegap 应用没有网络连接

问题描述

我有一个可以在除 9 Pie 之外的所有 Android 版本上运行的 phonegap 应用程序。

导航到网站工作。这意味着我的允许导航标签必须是正确的。但是发送一个 XMLHttpRequest 我没有得到任何数据。

		var xmlhttp = new XMLHttpRequest();
		xmlhttp.onreadystatechange = function(){
     if(xmlhttp.readyState==4){
				if(xmlhttp.status==200){
				  var info = xmlhttp.responseXML;
				  if(info!=null){
					  //doLog(xmlhttp.responseText);
				    ...
				  }
				} else {
					doLog("Server answer: " + xmlhttp.status + " " + xmlhttp.statusText);
				}
      }
    }
		xmlhttp.open("GET", serverURL + url, true);
		xmlhttp.send();	

我读到您需要 minSdkVersion 17 才能使应用程序与 android 9 一起使用。我的已经有 19 个。TargetSdkVersion 为 28。

当然我使用白名单插件。

    <preference name="phonegap-version" value="cli-8.2.2" />
        <preference name="keepRunning" value="true" />
        <preference name="android-minSdkVersion" value="19" />
        <preference name="android-targetSdkVersion" value="28" />
        <preference name="android-build-tool" value="gradle" />
    <access launch-external="yes" origin="geo:*" />
    <access launch-external="yes" origin="mailto:*" />
    <access launch-external="yes" origin="http://*" />
    <access launch-external="yes" origin="https://*" />
    <access origin="*" />
    <allow-navigation href="http://*/*" />
    <allow-navigation href="https://*/*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />

任何人的想法?

标签: phonegapandroid-9.0-pie

解决方案


问题消失了。在此版本构建之前我所做的更改:添加

<preference name="phonegap-version" value="cli-8.2.2" />

重新安装白名单插件。


推荐阅读