-
android Resources.getSystem() mocking 처리Android 2020. 7. 15. 12:56반응형
Junit 으로 태스트 코드를 돌릴 경우 Resources.getSystem() 가 있을때 아래와 같은 error 가 발생합니다.
Caused by: java.lang.IllegalStateException: Resources.getSystem() must not be null
이럴경우 Resources.getSystem() 를 safenull 처리하여 null일 경우 기본값을 출력하도록 합니다
ex)
@JvmStatic val WIDTH_PIXEL = Resources.getSystem()?.displayMetrics?.widthPixels ?: 0
반응형'Android' 카테고리의 다른 글
Android TextView URL link 처리하기 (0) 2020.12.28 Gson v 2.8.6 공식 번역본 (0) 2020.10.14 ConstraintLayout에서 match_parent 가 작동 안될경우 (0) 2020.09.21 Hilt 공식 문서 번역본 (0) 2020.07.24 Android11: The Beta Launch Show (0) 2020.06.04 Android APK 파일 서명 (with. Apk Sign) (0) 2020.02.10 APKTOOL 설치 방법 (0) 2020.02.08 Build a Modular Android App Architecture (Google I/O'19) (0) 2020.02.07