huzit
___을 입력해주세요
huzit
전체 방문자
  • 분류 전체보기 (137)
    • 안드로이드(Compose) (10)
      • UI (4)
      • 개념 (6)
    • 안드로이드 (50)
      • 기본개념 (6)
      • 응용 (4)
      • Debug (18)
      • Binding (3)
      • RecyclerView (5)
      • Firebase (6)
      • Retrofit (1)
      • Activity & Fragment (4)
    • 코틀린 (22)
    • 코딩테스트 (38)
      • 백준 (10)
      • 프로그래머스 (28)
    • 일상 (6)
    • CS 지식 (4)
    • 라즈베리파이 (7)

블로그 메뉴

  • 홈
  • 태그
  • 글쓰기
  • 관리

공지사항

인기 글

태그

  • Kotlin
  • 라즈베리 파이
  • 코틀린
  • 공돌카돈
  • recyclerView ClickEvent
  • gts4mini
  • compose
  • Java
  • jetpack
  • 공돌이파파
  • 프로그래머스
  • RecyclerView
  • FCM
  • firebase
  • docker
  • Debug
  • Retrofit
  • Android
  • IFTTT
  • 브레빌 밤비노 플러스

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
huzit

___을 입력해주세요

NetworkOnMainThreadException
안드로이드/Debug

NetworkOnMainThreadException

2023. 6. 28. 14:46
728x90

원인

안드로이드에서 네트워크 작업은 메인 스레드가 아닌 작업스레드에서 해야함

해결

kotlin이면 CoroutinScope(Dispacher.Default).launch{} 로 감싸면 해결

자바면 쓰레드 하나 만들어주면 된다.

728x90
저작자표시 (새창열림)

'안드로이드 > Debug' 카테고리의 다른 글

IllegalStateException:no event down from INITIALIZED in component androidx.navigation.NavBackStackEntry  (0) 2023.09.06
Unable to add window -- token null is not valid; is your activity running?  (0) 2023.08.02
java.lang.OutOfMemoryError: Failed to allocate a 186909536 byte allocation with 25165824 free bytes and 134MB until OOM, target footprint 152658392, growth limit 268435456  (0) 2023.06.26
[Retrofit 통신 실패]java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 2 path $  (0) 2023.06.20
Key 1 was already used. If you are using LazyColumn/Row please make sure you provide a unique key for each item.  (0) 2023.06.14
    '안드로이드/Debug' 카테고리의 다른 글
    • IllegalStateException:no event down from INITIALIZED in component androidx.navigation.NavBackStackEntry
    • Unable to add window -- token null is not valid; is your activity running?
    • java.lang.OutOfMemoryError: Failed to allocate a 186909536 byte allocation with 25165824 free bytes and 134MB until OOM, target footprint 152658392, growth limit 268435456
    • [Retrofit 통신 실패]java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 2 path $
    huzit
    huzit
    simple is best

    티스토리툴바