전체 글
-
[Android]AppDatabase_lmpl does not exist(Room)Debugging 2021. 9. 8. 09:36
Kotlin을 사용하는 경우 앱 build.gradle에서 annotationProcessor를 kapt로 변경하고 gradle plugin 추가한다. apply plugin: 'kotlin-kapt' dependencies { def room_version = "2.3.0" // check latest version from docs ... implementation "androidx.room:room-ktx:$room_version" kapt "androidx.room:room-compiler:$room_version" }
-
Using Room DB with HiltDI 2021. 8. 23. 19:24
설정 android { ... kotlinOptions { jvmTarget = "1.8" } } dependencies{ def room_version = "2.3.0" // check latest version from docs ... implementation "androidx.room:room-ktx:$room_version" kapt "androidx.room:room-compiler:$room_version" } compiler options android { defaultConfig { javaCompileOptions { annotationProcessorOptions { arguments += [ "room.schemaLocation":"$projectDir/schemas".toStrin..
-
Hilt를 사용한 의존성 주입 시작하기DI 2021. 8. 22. 14:41
Hilt 라이브러리는 프로젝트의 모든 Android 클래스에 컨테이너를 제공하고 자동으로 수명주기를 관리하여 애플리케이션에서 DI를 수행하는 표준 방법을 정의한다. Hilt 목표 1. Android 앱용 Dagger 관련 인프라를 단순화한다. 2. 앱 간의 설정, 가독성/이해 및 코드 공유를 용이하게 하기 위해 표준 구성 요소 및 범위 세트를 생성한다. 3. 다양한 빌드 유형(예: 테스트, 디버그 또는 릴리스)에 서로 다른 바인딩을 공급하는 쉬운 방법을 제공한다. 설정 프로젝트의 루트 build.gradle 파일에 종속 항목을 추가 buildscript { ... dependencies { ... classpath 'com.google.dagger:hilt-android-gradle-plugin:2.28..
-
RxLifecycle 라이브러리ReactiveX 2021. 8. 22. 11:50
이 라이브러리는 불완전한 구독으로 인해 메모리 누수가 발생할 수있는 Android에서 유용하며 안드로이드의 라이프 사이클에 맞게 Observable을 관리할 수 있는 Components를 제공한다. 설정 app/build.gradle 파일에 종속 항목을 추가 // If you want pre-written Activities and Fragments you can subclass as providers implementation 'com.trello.rxlifecycle4:rxlifecycle-components:4.0.2' // If you want pre-written support preference Fragments you can subclass as providers implementation ..
-
RxPermissions, RxBinding 라이브러리ReactiveX 2021. 8. 17. 20:33
1. RxPermissions Library RxJava에서 제공하는 Android 런타임 권한 라이브러리(Beta 버전) Dependencies allprojects { repositories { ... maven { url 'https://jitpack.io' } } } dependencies { implementation 'com.github.tbruyelle:rxpermissions:0.12' } 사용법(Kotlin) val rxPermissions = RxPermissions(this) // where this is an Activity or Fragment instance Frament에서 RxPermissions를 사용하는 경우 RxPermissions (fragment.getActivity..
-
FragmentAndroid 2021. 8. 16. 11:28
프래그먼트 장단점 프래그먼트 장점 퍼포먼스 - Activity보다 상대적으로 가볍다 - Activity내에서 Fragment는 상대적으로 가볍게 추가/제거가 가능하다. Fragment 백스택에서 Fragment를 관리하는 것이 메모리 관리면에서도 효율적이며, 화면 전환도 Activity보다 더 순조롭게 할 수 있다. 유연한 UI/UX 구현 - Fragment는 기본적으로 큰 화면에서 역동적이고 유연한 UI 디자인을 지원하는 것이 목적이었다. - NavigationDrawer, BottomSheetDialog, Navigation Component 등을 구현할 때도 사용된다. 재사용성의 증가 - View or Business Logic을 Fragment 단위로 분리 가능하다. 프래그먼트 단점 비동기로 인해..
-
Replace findViewById with View BindingAndroid 2021. 8. 6. 12:57
View Binding 기능을 사용하면 뷰와 상호작용하는 코드를 쉽게 작성할 수 있다. (대부분의 경우 view binding으로 findViewById가 대체 가능하다) View Binding은 Android Studio 3.6 Canary 11 이상에서 사용할 수 있다. 설정 build.gradle(module:app) 파일에 kotlin-android-extensions 플러그인을 삭제하고 다음 dependencies를 추가한다. android { ... buildFeatures.viewBinding true } binding class를 생성하는 동안 레이아웃 파일을 무시하려면 tools:viewBindingIgnore="true" 속성을 레이아웃 파일의 root view에 추가한다. 사용 모듈에..
-
ANR(Application Not Responding)Android 2021. 7. 19. 10:29
ANR 메세지는 어느 동작에서 메인 스레드를 오랫동안 점유하고 있다는 의미이다. 다음 조건 중 하나가 발생하면 앱과 관련한 ANR이 트리거 된다. Activity가 foreground인 경우 input event(예 : 키 누름 또는 화면 터치 이벤트) 또는 Broadcast Receiver에 5초 이내 응답하지 않은 경우 foreground에 activity가 없을 때 Broadcast Receiver가 상당한 시간 내에 실행을 완료하지 못한 경우 ANR Timeout ANR 타임아웃을 프레임워크 소스에서 확인해보면 아래와 같다. // How long we allow a receiver to run before giving up on it. static final int BROADCAST_FG_TIME..