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

FATAL EXCEPTION: main
                 Process: com.example.myapplication, PID: 25658
                 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3876)
                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4018)
                     at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:111)
                     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:2474)
                     at android.os.Handler.dispatchMessage(Handler.java:106)
                     at android.os.Looper.loopOnce(Looper.java:240)
                     at android.os.Looper.loop(Looper.java:351)
                     at android.app.ActivityThread.main(ActivityThread.java:8422)
                     at java.lang.reflect.Method.invoke(Native Method)
                     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
                 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.example.myapplication.MainActivity.onCreate(MainActivity.java:12)
                     at android.app.Activity.performCreate(Activity.java:8422)
                     at android.app.Activity.performCreate(Activity.java:8395)
                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1403)
                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3849)
                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4018) 
                     at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:111) 
                     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:2474) 
                     at android.os.Handler.dispatchMessage(Handler.java:106) 
                     at android.os.Looper.loopOnce(Looper.java:240) 
                     at android.os.Looper.loop(Looper.java:351) 
                     at android.app.ActivityThread.main(ActivityThread.java:8422) 
                     at java.lang.reflect.Method.invoke(Native Method) 
                     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584) 
                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013) 

 

            android:theme="@style/Theme.AppCompat.Light
implementation 'androidx.appcompat:appcompat:1.3.1'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值