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 应用服务中间件 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.
554 0
|
3月前
|
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”?
29 1
|
8月前
|
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的解决方案
|
9月前
|
存储 前端开发 Java
【Java】If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
【Java】If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
129 0
|
10月前
|
Java 开发工具 Android开发
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.
|
11月前
|
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”?
|
SQL Java 关系型数据库
【已解决】Mybatis 批量动态更新数据时出现异常:java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax
【已解决】Mybatis 批量动态更新数据时出现异常:java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax
597 0
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this a
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this a
|
Java jenkins 持续交付
jenkins启动失败,提示Starting Jenkins Jenkins requires Java8 or later, but you are running 1.7.0
# 背景 centos安装jenkins后,先启动jenkins服务,结果报错如下: 但自己明明已经安装了java8的 # 解决方法 既然安装了java8的话,那么证明是jenkins启动的是还是用的旧的java7,需要修改jenkins启动引用的java版本,是在/etc/init.
3382 0
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.
1347 0