0

i am losing my mind over this... i cant get my api to work... cordova app calls an http:// and i allways recive net::ERR_CLEARTEXT_NOT_PERMITTED ..i think i tried everything...

my 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>

my 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>

im using phonegap ... it builds ok but i cant get pass the error ... i also have tried cordova-plugin-enable-cleartext-traffic plugin with no sucess... can anyone help ?

Bruno Alex
  • 63
  • 3
  • 13
  • Does this answer your question? [Why am I seeing net::ERR\_CLEARTEXT\_NOT\_PERMITTED errors after upgrading to Cordova Android 8?](https://stackoverflow.com/questions/54752716/why-am-i-seeing-neterr-cleartext-not-permitted-errors-after-upgrading-to-cordo) – Clockwork Jul 07 '22 at 08:21

1 Answers1

0

well it seams that i fixed this with:

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

and by removing all the other things, including the plugin :)

Bruno Alex
  • 63
  • 3
  • 13