0

Ok So I have the following in my manifest file but I am still getting the clear text is not allowed on IP address 192.168 which is a local IP address range please help driving me nuts. I am using Xamrain forms.

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
  <base-config cleartextTrafficPermitted="true" >
  </base-config>
</network-security-config>

I have it set as an embbed resource file at the following location enter image description here

enter image description here

My Manafest file is as follows

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.companyname.FuelStockApp" android:installLocation="auto" android:versionCode="2" android:versionName="1.0">
    <uses-sdk android:minSdkVersion="24" android:targetSdkVersion="28" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_SMS" />
    <uses-permission android:name="android.permission.WRITE_USER_DICTIONARY" />
    <application android:label="FuelStockApp.Android"></application>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
   <application android:usesCleartextTraffic="true"
    android:networkSecurityConfig="@xml/network_security_config">

 </application>
 </manifest>

I have it also here as a sanity check

c-sharp-and-swiftui-devni
  • 3,743
  • 4
  • 39
  • 100
  • Have you tested it on a real device? I only set `android:usesCleartextTraffic` in my app's manifest, it works fine. You can try to use `android:networkSecurityConfig` to specify a special domain which allows clear text as I haven't test local domain. Refer to this thread for more options: https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted – Ax1le Jun 13 '19 at 03:10
  • Yes I have a google pixel 3a i am on a local area network so dont have a domain @LandLu-MSFT – c-sharp-and-swiftui-devni Jun 13 '19 at 06:24
  • I've noticed 192.168 IP address. This is your local domain. – Ax1le Jun 13 '19 at 07:08
  • @LandLu-MSFT yes that is correct so what way would i need to have the above configuration to make this work at present its still givein me denied. – c-sharp-and-swiftui-devni Jun 13 '19 at 07:53
  • It still failed when you tried this option: ` Your URL(ex: 127.0.0.1) `? – Ax1le Jun 13 '19 at 07:55
  • @LandLu-MSFT i have not tried it that why I will check this when i am home – c-sharp-and-swiftui-devni Jun 13 '19 at 07:58

1 Answers1

1

In your network_config_xml add the ip's that you want to be excluded.

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
  <domain-config cleartextTrafficPermitted="true">
    <domain includeSubdomains="true">10.0.2.2</domain> 
    <domain includeSubdomains="true"> 192.168.0.0</domain> <!-- Your IP's  -->
  </domain-config>
</network-security-config>

In your manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.companyname.FuelStockApp" android:installLocation="auto" android:versionCode="2" android:versionName="1.0">
    <uses-sdk android:minSdkVersion="24" android:targetSdkVersion="28" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_SMS" />
    <uses-permission android:name="android.permission.WRITE_USER_DICTIONARY" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />

 <application android:label="FuelStockApp.Android" android:networkSecurityConfig="@xml/network_security_config" ></application>


 </application>
Bruno Caceiro
  • 7,035
  • 1
  • 26
  • 45