🐛 requireContext IllegalStateException
requireContext()의 원형을 살펴보면
    /**
     * Return the {@link Context} this fragment is currently associated with.
     *
     * @throws IllegalStateException if not currently associated with a context.
     * @see #getContext()
     */
    @NonNull
    public final Context requireContext() {
        Context context = getContext();
        if (context == null) {
            throw new IllegalStateException("Fragment " + this + " not attached to a context.");
        }
        return context;
    }
@NonNull이기 때문에, null이면 IllegalStateException이 발생합니다.
만약 Fragment가 Activity에 연결되어 있지 않거나, Fragment가 이미 detach된 상태에서 호출될 때 발생하기에
🔑 non-null 체크 후에 사용하기 혹은 getContext 사용하기
'🐛 버그' 카테고리의 다른 글
| [Android / Retrofit] End of input at line 1 column 1 path $ (1) | 2024.09.13 | 
|---|---|
| [Bug / RecyclerView] java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionNotificationHolder (2) | 2024.05.20 | 
| [Bug / Android] Glide ImageView 깜빡임 해결 (0) | 2023.08.27 | 
| [Android] Cannot inherit from final class error (0) | 2020.12.21 | 
| WindowManager$BadTokenException (0) | 2020.12.15 |