[Android 9.0][Debugging] CLEARTEXT communication to XXXX not permitted by network security policy

2019. 3. 22. 22:30Programing/Debugging

 

 

[Android P 변경 사항]

HTTPS를 기본값으로 지정
모든 네트워크 트래픽을 일반 텍스트(Cleartext - 암호화되지 않은 HTTP)에서 TLS로 보호된 웹사이트(HTTPS)로 전환하기 위한 광범위한 노력의 일환으로, 모든 HTTP 트래픽을 차단하도록 네트워크 보안 구성의 기본값을 변경하는 중입니다. HTTP 연결은 특정 도메인에 대해 일반 텍스트 사용을 명시적으로 선언한 경우에만 허용됩니다. 자세한 내용은 여기를 참조하세요.

https://developers-kr.googleblog.com/2018/08/introducing-android-9-pie.html

 

 

Google에서 정책을 발표한 것 처럼, 안드로이드 파이부터는 HTTP를 강제하고 있습니다. 

URL 주소가 HTTP로 되어 있는 경우, 아래와 같은 Error를 Return하게 됩니다.

CLEARTEXT communication to XXXX not permitted by network security policy

Cleartext traffic not permitted

 

 

 

[Simple Solution]

Method 1. Change address to "HTTPS" instead of "HTTP" if it's supported.

Method 2. Official Method

https://android-developers.googleblog.com/2018/04/protecting-users-with-tls-by-default-in.html

https://developer.android.com/training/articles/security-config.html

Method 3. Set "usesCleartextTraffic" as "true"

<application
...
android:usesCleartextTraffic="true">