净:: ERR_CLEARTEXT_NOT_PERMITTED phonegap /科尔多瓦

问题描述

我对此失去了主意...我无法使我的api正常工作...科尔多瓦应用程序调用了http://,并且我一直都能收到net :: ERR_CLEARTEXT_NOT_PERMITTED ..我认为我已经尝试了所有...... / p>

我的config.xml:

<widget id="app.com" version="20320" 
xmlns="http://www.w3.org/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:cdv="http://cordova.apache.org/ns/1.0">

 
  <name>appFree</name>
  <description>app.</description>
  <author href=" ">Bruno ALexandre</author>
  <content src="index.html"/>
 
  <preference name="DisallowOverscroll" value="true"/>
  <preference name="android-targetSdkVersion"     value="28" />   
  <preference name="android-minSdkVersion" value="18" />
  <preference name="phonegap-version" value="cli-8.0.0" />
 <!--  <preference name="AndroidPersistentFileLocation" value="Compatibility" />  -->


  <plugin name="cordova-plugin-enable-cleartext-traffic" source="npm"   /> 
  <!-- <plugin name="cordova-android-support-gradle-release" source="npm"   />    -->
  <plugin name="cordova-plugin-android-permissions" spec="^1.0.0" />
  <plugin name="cordova-plugin-camera"  />  
 
  <!-- <plugin name="cordova-plugin-file" source="npm"  /> -->
  <plugin name="cordova-plugin-inappbrowser" source="npm" /> 
 <!--  <plugin name="cordova-plugin-media" source="npm"  />  -->
  <plugin name="cordova-plugin-whitelist" source="npm" />
  <plugin name="cordova-plugin-apprate"/>
  <plugin name="cordova-plugin-dialogs" source="npm"   />
  <plugin name="cordova.diagnostic.plugin" source="npm"   />
  <plugin name="cordova-plugin-media-capture" source="npm"  />  
  <plugin name="cordova-plugin-device" source="npm"/> 

 
  <icon src="www/icon.png"/>


<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
      <application android:usesCleartextTraffic="true" />
  </edit-config>


<platform name="android">
<allow-intent href="market:*" />
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:usesCleartextTraffic="true" />
<application android:networkSecurityConfig="@xml/network_security_config" />
</edit-config>
<resource-file src="www/resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />


  <config-file after="uses-permission" parent="/manifest" target="AndroidManifest.xml">
  <uses-permission android:name="android.permission.CAMERA" />
  <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.FLASHLIGHT" /> 
  <uses-permission android:name="android.permission.WRITE_SETTINGS" />
  </config-file>

</platform>
 
  <access origin="mailto:*" launch-external="yes" />
  <access origin="*"/>
  <allow-navigation href="*" />
  <allow-intent href="http://*/*"/>
  <allow-intent href="https://*/*"/>
  <allow-intent href="tel:*"/>
  <allow-intent href="sms:*"/>
  <allow-intent href="mailto:*"/>
  <allow-intent href="geo:*"/>
  <platform name="android">
  <allow-intent href="market:*"/> 
  <allow-navigation href="*" />
  </platform>
 

</widget>

我的network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" />
        </trust-anchors>
    </base-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">localhost</domain>
        <domain includeSubdomains="true">myadress.com</domain>
         <domain includeSubdomains="true"></domain>
    </domain-config>
</network-security-config>

我正在使用phonegap ...它可以正常运行,但我无法通过错误...我也已经尝试过 cordova-plugin-enable-cleartext-traffic插件,没有成功...任何人都可以帮忙吗?

解决方法

我用以下方法解决了这个问题:

  <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
            <application android:usesCleartextTraffic="true" />
        </edit-config>

并删除所有其他内容,包括插件:)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...