1

My app was working fine until Hostgator renewed by domain and enabled https using free SSL. Now i m getting below error while running app on some devices specially with Android 24 (7.0), whereas on android 30 and above apps is working fine.

i followed many links on stackoverflow and android docs to handle this issue, but still not resolved. It seems i m still missing some fix. Can you help.

Here is the Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.internetdatasendcheck">

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:networkSecurityConfig="@xml/network_security_config"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.InternetDataSendCheck"
        android:usesCleartextTraffic="true">

        <activity
            android:name=".MainActivity"
            android:exported="true">

            <intent-filter>
                <category android:name="android.intent.category.LAUNCHER" />
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>

        </activity>


    </application>

</manifest>

My Network xml:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <debug-overrides>
        <trust-anchors>
            <domain includeSubdomains="true">https://innovativeapps.me</domain>
        </trust-anchors>
    </debug-overrides>


</network-security-config>

My Mainactivity to connect with server:

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    URL checkurl = new URL("https://innovativeapps.me");
                    HttpURLConnection conn = (HttpURLConnection) checkurl.openConnection();
                    conn.connect();
                    String response = conn.getResponseMessage();
                    Log.i("Response: ",conn.getResponseMessage() + conn.getResponseCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        thread.start();

    }
}
Panache
  • 1,701
  • 3
  • 19
  • 33

1 Answers1

-1

Did you try following in manifest file?

<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<uses-permission android:name="android.permission.INTERNET" />
<application
    ...
    android:usesCleartextTraffic="true"
    ...>
    ...
</application>
</manifest>

you can check this link also Android 8: Cleartext HTTP traffic not permitted

Pankaj Bansal
  • 367
  • 4
  • 17