崩溃:您需要使用Theme.AppCompat主题。

huangapple 未分类评论44阅读模式
英文:

Crash: You need to use a Theme.AppCompat theme

问题

以下是您的翻译内容:

我的应用在 Android 6 以下崩溃。以下是我的错误日志:

05-19 12:38:13.682 24304-24304/com.example.find E/AndroidRuntime: 致命异常: 主线程
java.lang.RuntimeException: 无法启动组件信息{com.example.find/com.example.find.MainActivity}: java.lang.IllegalStateException: 您需要在此活动中使用 Theme.AppCompat 主题(或其子类)。
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2114)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2139)
    at android.app.ActivityThread.access$700(ActivityThread.java:143)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4960)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
    at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.IllegalStateException: 您需要在此活动中使用 Theme.AppCompat 主题(或其子类)。
    at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:696)
    at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:659)
    at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:552)
    at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
    at com.example.find.MainActivity.onCreate(MainActivity.java:24)
    at android.app.Activity.performCreate(Activity.java:5203)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2078)

我的 styles.xml:

<style name="AppTheme" parent="Theme.AppCompat">
    <item name="android:titleTextColor">@color/colorAccent</item>
    <item name="colorPrimary">@color/colorAccent</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
</style>

<style name="AppFullScreenTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

我的 Manifest:

        android:theme="@style/Theme.AppCompat">
    <activity android:name=".Time" android:theme="@style/AppFullScreenTheme" android:label="Wysyłaj lokalizację czasowo"></activity>
    <activity android:name=".Settings"  android:theme="@style/AppFullScreenTheme" android:label="Ustawienia"/>
    <activity
        android:name=".MainActivity"
        android:theme="@style/AppFullScreenTheme">

我尝试寻找解决方案,但它们对我没有起作用。我知道我可能需要在样式中做一些更改,我尝试了,但对我来说仍然不起作用。谢谢。

英文:

My app crashes below Android 6. Here is my Error log:

05-19 12:38:13.682 24304-24304/com.example.find E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.find/com.example.find.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2114)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2139)
    at android.app.ActivityThread.access$700(ActivityThread.java:143)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4960)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
    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 androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:696)
    at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:659)
    at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:552)
    at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
    at com.example.find.MainActivity.onCreate(MainActivity.java:24)
    at android.app.Activity.performCreate(Activity.java:5203)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2078)

My styles.xml:

&lt;style name=&quot;AppTheme&quot; parent=&quot;Theme.AppCompat&quot;&gt;
    &lt;item name=&quot;android:titleTextColor&quot;&gt;@color/colorAccent&lt;/item&gt;
    &lt;item name=&quot;colorPrimary&quot;&gt;@color/colorAccent&lt;/item&gt;
    &lt;item name=&quot;colorPrimaryDark&quot;&gt;@color/colorPrimaryDark&lt;/item&gt;
&lt;/style&gt;

&lt;style name=&quot;AppFullScreenTheme&quot; parent=&quot;Theme.AppCompat.Light.NoActionBar&quot;&gt;
    &lt;item name=&quot;android:windowNoTitle&quot;&gt;true&lt;/item&gt;
    &lt;item name=&quot;android:windowActionBar&quot;&gt;false&lt;/item&gt;
    &lt;item name=&quot;android:windowFullscreen&quot;&gt;true&lt;/item&gt;
    &lt;item name=&quot;android:windowContentOverlay&quot;&gt;@null&lt;/item&gt;
&lt;/style&gt;

My Manifest:

        android:theme=&quot;@style/Theme.AppCompat&quot;&gt;
    &lt;activity android:name=&quot;.Time&quot; android:theme=&quot;@style/AppFullScreenTheme&quot; android:label=&quot;Wysyłaj lokalizację czasowo&quot;&gt;&lt;/activity&gt;
    &lt;activity android:name=&quot;.Settings&quot;  android:theme=&quot;@style/AppFullScreenTheme&quot; android:label=&quot;Ustawienia&quot;/&gt;
    &lt;activity
        android:name=&quot;.MainActivity&quot;
        android:theme=&quot;@style/AppFullScreenTheme&quot;&gt;

I was looking for solutions, but they didn't work for me. I know I must change something in styles probably, I tried to do it, but it still doesnt work for me. Thank you

huangapple
  • 本文由 发表于 2020年5月19日 18:52:36
  • 转载请务必保留本文链接:https://java.coder-hub.com/61889266.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定