Android Приложение не подключается к HTTP WEBSERIVE - PullRequest
0 голосов
/ 08 мая 2020

У меня целевая версия SDK - 28. И мой веб-сервис - HTTP.

и добавлен этот код

added this xml file: network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
    <domain includeSubdomains="true">your_domain.com</domain>
</domain-config>

добавил эти 2 строки кода в манифест файл:

android:usesCleartextTraffic="true"

android:networkSecurityConfig="@xml/network_security_config"

Но все еще не подключается к серверу.

Пожалуйста, помогите мне.

Любой предложения будут признательны.

manifest file

network config file

error

1 Ответ

0 голосов
/ 08 мая 2020

Попробуйте добавить этот код в свой тег <application/>.

<uses-library
            android:name="org.apache.http.legacy"
            android:required="false" />

вот так:

<application
        android:largeHeap="true"
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:roundIcon="@drawable/icon"
        android:supportsRtl="true"
        android:usesCleartextTraffic="true"
        android:networkSecurityConfig="@xml/network_security_config"
        android:theme="@style/AppTheme.NoActionBar">
        <uses-library
            android:name="org.apache.http.legacy"
            android:required="false" />
        <activity
            android:name=".SplashActivity"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
</application>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...