(작성중) [코틀린(Kotlin)] 에러해결: android.os.NetworkOnMainThreadException
2022. 9. 14. 01:35
문제/에러
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.learnandroid.loginapplication, PID: 18766
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.learnandroid.loginapplication/com.learnandroid.loginapplication.MainActivity}: android.os.NetworkOnMainThreadException
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: android.os.NetworkOnMainThreadException
해결방법
thread 키워드 사용
링크 : https://manhyuk.github.io/kotlin-corutine/
참고하기