java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

지프치프·2021년 10월 3일
0

Issue(error)

목록 보기
4/20

개요

새로운 개인 프로젝트를 진행하기 위해서
프로젝트를 새로 만들고 Splash까지 만들고 빌드 해봤더니
위 에러가 발생했다.

2021-10-03 14:39:18.720 475-475/com.example.quickmemo E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.quickmemo, PID: 475
    java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
        at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:846)
        at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:809)
        at androidx.appcompat.app.AppCompatDelegateImpl.onPostCreate(AppCompatDelegateImpl.java:530)
        at androidx.appcompat.app.AppCompatActivity.onPostCreate(AppCompatActivity.java:151)
        at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1373)
        at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3321)
        at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
        at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

해결

Log를 보면 힌트를 찾을 수 있었다.
You need to use a Theme.AppCompat theme (or descendant) with this activity.

그래서 themes.xml를 확인해봤는데 이상이 없어보였..는데?

망할 야간모드

style.xml이 themes.xml로 바뀐 후로
라이트 모드와 다크 모드(night)로 나뉘었는데
splash에 쓰일 style을 다크 모드 themes.xml에 정의해서 충돌이 일어났던 거 같다.

그래서 splash style을 라이트 모드 themes.xml에 옮겨주고
parent를 AppCompat.NoActionBar로 바꿔주고 빌드해보니
정상적으로 실행되었다.

개인적으로 공부했던 것을 바탕으로 작성하다보니
잘못된 정보가 있을수도 있습니다.
인지하게 되면 추후 수정하겠습니다.
피드백은 언제나 환영합니다.
읽어주셔서 감사합니다.

profile
지프처럼 거침없는 개발을 하고싶은 개발자

0개의 댓글