如何解决此活动需要使用 Theme.AppCompat 主题(或后代)

问题描述 投票:0回答:1

我有一个 SplashActivity 显示错误

android.splash.ui.SplashActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

这是在我添加依赖项后开始的

implementation ("com.github.espressif:esp-idf-provisioning-android:lib-2.1.2")

SplashActivity 清单

<application
    android:name=".OApp"
    android:allowBackup="false"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme.NoActionBar"
    android:usesCleartextTraffic="${ClearTextEnabled}"
    android:requestLegacyExternalStorage="true"
    tools:ignore="GoogleAppIndexingWarning">

    <!-- Activities -->
    <activity
        android:name=".splash.ui.SplashActivity"
        android:launchMode="singleTask"
        android:exported="true"
        android:configChanges="orientation"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter android:order="0">
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="cpoints.opark.com"
                android:pathPattern="${DeepLinkBrand}"
                android:scheme="https" />
        </intent-filter>
    </activity>

splash_ativvyt.xml 看起来像这样

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/coordinatorLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".splash.ui.SplashActivity">

    <FrameLayout
        android:id="@+id/fragmentContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <include layout="@layout/loading_view_white_bg"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

您能建议我做什么来消除这个错误吗

提前致谢 R

android kotlin android-activity android-manifest
1个回答
0
投票

您的代码看起来正确。您尚未提供

styles.xml
文件中的代码,因此请确保您的
AppTheme.NoActionBar
样式继承自
Theme.AppCompat
。它应该看起来像这样:

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat">
    <!-- Your attributes -->
</style>
© www.soinside.com 2019 - 2024. All rights reserved.