안드로이드

    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..

    Firebase Crashlytics 시작하기

    Firebase Crashlytics 시작하기

    앱을 개발하다 보면 필드 테스트를 해야 하거나 배포 후 에러 관리를 해야 합니다. 그럴 때 필요한 게 좋은 에러관리 플랫폼입니다. 파이어 베이스는 이것마저 무료로 제공하고 있습니다. https://firebase.google.com/docs/crashlytics/get-started?platform=android&hl=ko#add-sdk 방법 프로젝트 추가방법에 관해선 지난 게시글을 보시는 걸 추천드립니다. Firebase 시작하기 Firebase Firebase는 고품질 앱을 빠르게 개발하고 비즈니스를 성장시키는 데 도움이 되는 Google의 모바일 플랫폼입니다. firebase.google.com 파이어베이스에 개인 프로젝트를 추가하는 방법에 대해 다뤄 huzit.tistory.com 앱에 Crash..

    Firebase 시작하기

    Firebase 시작하기

    plugins { // ... id("com.google.gms.google-services") version "4.3.15" apply false }​ Firebase Firebase는 고품질 앱을 빠르게 개발하고 비즈니스를 성장시키는 데 도움이 되는 Google의 모바일 플랫폼입니다. firebase.google.com 파이어베이스에 개인 프로젝트를 추가하는 방법에 대해 다뤄볼까 합니다. 파이어베이스에 대해 간단히 소개하자면 개발자에게 편리한 기능을 "무료로" 쓸 수 있는 아주 위대한 플랫폼입니다. 특히 애널리틱스나 크래시리틱스는 앱을 배포하고 관리함에 있어서 아주 강력한 기능이기 때문에 꼭 추가하는 걸 추천드립니다. 파이어 베이스 프로젝트 생성 파이어베이스에 회원가입 후 콘솔로 이동하면 아래와 같은..

    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?, ..

    --- Failed to create image decoder with message 'unimplemented'

    --- Failed to create image decoder with message 'unimplemented'

    원인 Glide SVG이미지 로드 시 발생하는 에러, 버전에 따라 앱이 다운되는 경우도 있다. Glide.with(requireContext()).load(R.drawable.ic_sunny).into(binding.weatherIv) 해결 drawable 정수값 대신 ContextCompat.getDrawable로 호출 fun setImage(drawable: Int){ val image = ContextCompat.getDrawable(requireContext(), drawable) as VectorDrawable Glide.with(requireContext()).load(image).into(binding.weatherIv) } 참고 안드로이드 Glide SVG 이미지 로드 관련 오류 해결 - ..

    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)

    Navigation으로 Fragment전환을 쉽게 해보자 (feat.BottomNavigation)

    Navigation으로 Fragment전환을 쉽게 해보자 (feat.BottomNavigation)

    Fragment는 생각만 하면 머리가 아파오지만 안드로이드의 필수적인 기능임은 틀림없습니다. 하지만 화면 전환을 할 때만 되면 골치 아파지죠, 특히 프래그먼트간 전환을 할 때입니다. 기존 액티비티에서 프래그먼트로 이동할 때 FragmentManager()를 이용했습니다. 그리고 프래그먼트 간 전환을 하기 위해 우린 상위 액티비티에서 전환 이벤트를 전부 구현해줘야 했습니다. Activity to Fragment, Fragment to Fragment Fragment란? 사전적 의미로 Fragment란 조각을 의미한다. 우리가 앱을 개발하다보면 액티비티에 부분적인 화면을 추가하고 싶을 때가 있다. 특히, 한 액티비티에서 여러 화면이 전환되게 만들고 싶을 huzit.tistory.com 이런 불편하고 까다로운..

    플로우 차트(Flow Chart)

    플로우 차트(Flow Chart)

    회사에 들어가거나 팀 프로젝트를 하면 기획 단계에서 플로우 차트를 그려보란 말을 많이 들을 수 있습니다. 개발자가 개발만 하면 되지 그림까지 그릴 필요 있나? 하실 수 있지만 플로우 차트와 다양한 자료들을 기반으로 메뉴 설계와 화면 구성을 하기 때문에 직접 그리지 않아도 볼 줄 알아야 합니다. 또한 개인 프로젝트를 하시거나 토이 프로젝트를 할 때 순서도를 미리 그려놓고 작업하게 되면 개발 중 헤매는 일이 잘 없습니다. 헤매면 웃음밖에 안나오죠 개념 순서도(flow chart)는 워크플로 혹은 프로세스를 보여주는 다이어 그램의 한 종류입니다. 여러 종류의 상자와 이를 이어주는 화살표를 이용해 주어진 문제에 대한 솔루션 모델을 보여줍니다. 프로세스 작용은 이 같은 상자들과 작업의 흐름(workflow)을 나..