facebook twitter hatena line google mixi email

Android/開発環境/Android8

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

java.io.IOException: Cleartext HTTP traffic to example.com not permittedエラーが出る

Android8(compileSdkVersion 27)から必要

res/xml/network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">example.com</domain>
    </domain-config>
</network-security-config>

AndroidManifest.xml

<application
       android:networkSecurityConfig="@xml/network_security_config">
</application>

参考:https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted