Debug

    IllegalStateException:no event down from INITIALIZED in component androidx.navigation.NavBackStackEntry

    IllegalStateException:no event down from INITIALIZED in component androidx.navigation.NavBackStackEntry

    원인 Android Composed에서 Navigation이 일어났을 때 발생했습니다. 문제의 코드 navigateToQrMainPage = { navController.navigate("main_page"){ launchSingleTop = true restoreState = false popUpTo(navController.graph.startDestinationId){ saveState = true inclusive = true } } } 해결 From the androiddev community on Reddit Explore this post and more from the androiddev community www.reddit.com 레딧 이슈를 확인해 본 결과 Lifecycle 문제임을 찾..

    Unable to add window -- token null is not valid; is your activity running?

    Unable to add window -- token null is not valid; is your activity running?

    원인 Dialog에 context를 넘겨 줄 때 ApplicationContext를 넘겨주면 발생하는 에러 val dialog = BasicDialog(applicationContext) .setTitle("KeepMe에 업데이트가 필요합니다") .setMessage("이 앱을 사용하려면 최신 버전을 다운로드하세요.") .setPositiveButton("업데이트") { startActivity( Intent( Intent.ACTION_VIEW, Uri.parse(appUpdateURL) ) ) } 해결 현재 액티비티의 context를 넣어주거나 fragment일 경우 requireContext()로 context를 가져와 넘겨주면 된다 val dialog = BasicDialog(this) .setTi..

    NetworkOnMainThreadException

    NetworkOnMainThreadException

    원인 안드로이드에서 네트워크 작업은 메인 스레드가 아닌 작업스레드에서 해야함 해결 kotlin이면 CoroutinScope(Dispacher.Default).launch{} 로 감싸면 해결 자바면 쓰레드 하나 만들어주면 된다.

    Key 1 was already used. If you are using LazyColumn/Row please make sure you provide a unique key for each item.

    Key 1 was already used. If you are using LazyColumn/Row please make sure you provide a unique key for each item.

    원인 LazyColumn 또는 LazyRow를 쓸 때 각 항목에 고유한 위치값을 안 썼기 때문 LazyColumn에 item을 추가하는 기능을 만들었을 때 발생할 수 있다. 기본 레이아웃일 경우 자체적으로 처리되지만 커스텀일 경우 items의 key 패러미터에 고유한 key값을 넘겨줘야 한다. itemsIndexed( items = cl, key = { index: Int, item: CheckListInfo -> item.hashCode() } ) 나의 경우 key값으로 item의 해시 값을 넣어줬지만 내용이 같으면 해시값도 같으므로 위와 같은 에러가 발생했다. 해결 간단하다. 안겹치는 고유한 키 값을 주면 된다. itemsIndexed( items = cl, key = { index: Int, _: ..

    java.lang.NullPointerException: null cannot be cast to non-null type androidx.navigation.fragment.NavHostFragment

    java.lang.NullPointerException: null cannot be cast to non-null type androidx.navigation.fragment.NavHostFragment

    원인 BottomNavigation을 추가하던 중 val navHostFragment = supportFragmentManager.findFragmentById(R.id.fragmentContainer) as NavHostFragment 해결 private fun setBottomNav(){ val navHostFragment = supportFragmentManager.findFragmentById(R.id.fragmentContainer) as NavHostFragment //바텀 네비게이션에 들어갈 네비게이션 컨트롤러 정의 val navController = navHostFragment.findNavController() binding.bottomNav.setupWithNavController(na..

    RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{dcc7ca6 u0 com.***.***/.ble.BleService}

    RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{dcc7ca6 u0 com.***.***/.ble.BleService}

    원인 서비스에서 startForeground 호출 시점이 꼬이면 발생하는 예외 해결 onStartCommand() 에서 호출하던 startFroeground를 onCreate() 로 변경 private fun createNotificationChannel() { ... startForeground(NOTIFICATION_ID, notification) } broadcastUpdate(BleObject.START_FOREGROUND_SERVICE, "startForegroundService") } override fun onCreate() { super.onCreate() createNotificationChannel() } override fun onStartCommand(intent: Intent?, ..

    Caused by: java.lang.IllegalArgumentException: Char / is not a decimal digit

    Caused by: java.lang.IllegalArgumentException: Char / is not a decimal digit

    원인 StringBuilder에서 get한 값을 바로 digitToInt 했을 때 나온 에러입니다. if(sb[1].digitToInt() == 9) 해결 String -> Int 로 String을 한 번 거쳐줬습니다. if(sb[1].toString().toInt() == 9)

    SDK location not found

    SDK location not found

    원인 Git에서 프로젝트를 Pull 했는데 SDK 위치를 찾지 못함. 맥 -> 윈도우로 받아서 \, / 차이로 인한 오류라고 판단됩니다. 해결 방법 PC에서 sdk의 위치를 찾아 local.properties 파일에 넣어주면 됩니다. 만약 local.properties가 없다면 만들어주면 됩니다.