Kangho_Story

[안드로이드 코틀린 Kotlin] You need to use a Theme.AppCompat theme (or descendant) with this activity. 에러 해결 본문

Android

[안드로이드 코틀린 Kotlin] You need to use a Theme.AppCompat theme (or descendant) with this activity. 에러 해결

캉호 2024. 5. 1. 01:43
728x90
반응형

안드로이드 코틀린 프로젝트를 처음 만들고 실행하려는데 해당 에러가 발생했다.

더보기

FATAL EXCEPTION: main
                                                                                                    Process: com.CapstoneDesign.cityfarmer, PID: 19498
                                                                                                    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.CapstoneDesign.cityfarmer/com.CapstoneDesign.cityfarmer.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
                                                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
                                                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
                                                                                                     at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
                                                                                                     at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
                                                                                                     at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
                                                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
                                                                                                     at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                     at android.os.Looper.loop(Looper.java:223)
                                                                                                     at android.app.ActivityThread.main(ActivityThread.java:7656)
                                                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                                                     at cohttp://m.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
                                                                                                     at cohttp://m.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
                                                                                                    Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
                                                                                                     at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:926)
                                                                                                     at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:889)
                                                                                                     at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:772)
                                                                                                     at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:197)
                                                                                                     at com.CapstoneDesign.cityfarmer.MainActivity.onCreate(MainActivity.kt:13)
                                                                                                     at android.app.Activity.performCreate(Activity.java:7994)
                                                                                                     at android.app.Activity.performCreate(Activity.java:7978)
                                                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
                                                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
                                                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601) 
                                                                                                     at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) 
                                                                                                     at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
                                                                                                     at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
                                                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) 
                                                                                                     at android.os.Handler.dispatchMessage(Handler.java:106) 
                                                                                                     at android.os.Looper.loop(Looper.java:223) 
                                                                                                     at android.app.ActivityThread.main(ActivityThread.java:7656) 
                                                                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                     at cohttp://m.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
                                                                                                     at co http://m.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

열심히 찾아본 결과 application이 특정한 테마를 사용해야 하는데 그걸 안 해줘서 발생한 오류임을 알 수 있었다.

그래서 manifests에 들어가서 android:theme 부분을

 

 

android:theme ="@stlye/Theme.AppcCOmpat.Light.NoActionBar"로 변경해 주었다.

그랬더니 정상적으로 작동하였다. 문제 해결!

 

728x90
반응형
Comments