[코틀린(Kotlin)] 에러해결: java.io.IOException: Cleartext HTTP traffic to openapi.work.go.kr not permitted
2022. 9. 13. 22:29문제
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.learnandroid.loginapplication, PID: 17289
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.learnandroid.loginapplication/com.learnandroid.loginapplication.MainActivity}: java.io.IOException: Cleartext HTTP traffic to openapi.work.go.kr not permitted
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4035)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4201)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2438)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8663)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
Caused by: java.io.IOException: Cleartext HTTP traffic to openapi.work.go.kr not permitted
at com.android.okhttp.HttpHandler$CleartextURLFilter.checkURLPermitted(HttpHandler.java:127)
원인
앱이 기본적으로 Http 접근을 못하게 설정이 되어있다.(https는 가능) 그래서 http로 접근을 해야한다면 예외처리를 해줘야한다.
해결방법
AndroidManifest의 application 태그에서 android:usesCleartextTraffic="true"속성을 추가해준다.
https://codechacha.com/ko/android-cleartext-http-traffic-issue/