레이블이 ERR_CLEARTEXT_NOT_PERMITTED인 게시물을 표시합니다. 모든 게시물 표시
레이블이 ERR_CLEARTEXT_NOT_PERMITTED인 게시물을 표시합니다. 모든 게시물 표시

2019년 3월 2일 토요일

안드로이드9 HTTP Error - ERR_CLEARTEXT_NOT_PERMITTED

- 안드로이드 Pie 버전 부터 http 제한이 있습니다.
안드로이드 Pie : https://www.android.com/versions/pie-9-0/


1. ERR_CLEARTEXT_NOT_PERMITTED 오류
























WebView에서 http://www.google.com 으로 접속을 시도 하면 ERR_CLEARTEXT_NOT_PERMITTED 오류가 발생합니다.







2. 간단한 ERR_CLEARTEXT_NOT_PERMITTED 수정 방법
- AndroidManifest.xml 파일 수정.

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

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

    <application
        android:usesCleartextTraffic="true"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

- 결과
























http://www.google.com 으로 접속을 시도하면 정상적으로 표시됩니다.
android:usesCleartextTraffic="true" 라인을 추가해서 처리하는 방법은 추천하지 않습니다.
3번 내용을 확인하고 올바른 방법으로 대응하는 것을 권장합니다.








3. 자세한 내용
https://android-developers.googleblog.com/2018/04/protecting-users-with-tls-by-default-in.html
https://developer.android.com/about/versions/pie/android-9.0-changes-28?hl=ko