java.lang.IllegalStateException: You need to use a Theme.AppCompat theme

简介: 配置:中设置theme为 报错信息: 09-20 10:31:58.185 1392-1392/? E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: networkimageviewer.

配置:

中设置theme为

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"

        android:theme="@android:style/Theme.Light.NoTitleBar"
        android:label="@string/app_name"
        >

报错信息:

09-20 10:31:58.185    1392-1392/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: networkimageviewer.com.myapplication, PID: 1392
    java.lang.RuntimeException: Unable to start activity ComponentInfo{networkimageviewer.com.myapplication/networkimageviewer.com.myapplication.WelcomeActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2192)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2241)
            at android.app.ActivityThread.access$800(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1204)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5049)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
            at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:309)
            at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:278)
            at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:252)
            at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
            at networkimageviewer.com.myapplication.WelcomeActivity.onCreate(WelcomeActivity.java:22)
            at android.app.Activity.performCreate(Activity.java:5249)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2156)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2241)
            at android.app.ActivityThread.access$800(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1204)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5049)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
            at dalvik.system.NativeStart.main(Native Method)

解决办法:
To simply add ActionBar Compat your activity or application should use @style/Theme.AppCompat theme in AndroidManifest.xml like this:

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"

        android:theme="@style/Theme.AppCompat.Light.NoActionBar"
        android:label="@string/app_name"
        >

 

http://stackoverflow.com/questions/18063395/actionbarcompat-java-lang-illegalstateexception-you-need-to-use-a-theme-appcom

相关文章
|
6月前
|
Java Windows
windows下 安装 Elasticsearch报错warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
windows下 安装 Elasticsearch报错warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
433 0
|
Java 应用服务中间件 nginx
【异常解决】java程序连接MinIO报错The request signature we calculated does not match the signature you provided.
【异常解决】java程序连接MinIO报错The request signature we calculated does not match the signature you provided.
1899 0
|
5月前
|
Java
springboot 异常java.net.BindException: Address already in use: bind
springboot 异常java.net.BindException: Address already in use: bind
57 0
|
5月前
|
Java
ElasticSearch启动报错 java version is an early-access build ,only use release builds【已解决】
ElasticSearch启动报错 java version is an early-access build ,only use release builds【已解决】
63 0
|
6月前
|
定位技术 Android开发
Android 12蓝牙报java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission
Android 12蓝牙报java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission
231 1
|
IDE Java 开发工具
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8的解决方案
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8的解决方案
|
6月前
|
Java
Error:(15, 13) java: No property named “id” exists in source parameter(s). Did you mean “null”?
Error:(15, 13) java: No property named “id” exists in source parameter(s). Did you mean “null”?
129 1
|
Java
JAVA 端口被占用 报错解决方案:java.net.BindException: Address already in use: bind
JAVA 端口被占用 报错解决方案:java.net.BindException: Address already in use: bind
209 0
|
Java
【Java异常】com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: can not use this method fo
【Java异常】com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: can not use this method fo
556 0
java.net.BindException: Address already in use: 解决方法
java.net.BindException: Address already in use: 解决方法
321 0
下一篇
无影云桌面