java - Android Studio 在无法编辑的 XML 文件上出现 AAPT 错误

标签 java android xml

我正在尝试在 android studio 中设置 OpenCV,但每当我尝试构建我的项目时,我都会收到此错误

/home/oliver/AndroidStudioProjects/Opencvreal/app/build/intermediates
/packaged_manifests/debug/AndroidManifest.xml:33: AAPT: error: 
resource style/AppTheme (aka com.example.opencvreal:style/AppTheme) not found.

错误在于生成的 XML 文件,据我所知,该文件是不可编辑的。这是主要的和生成的 XML 文件

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="opencv.codeonion.com.opencv_test">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        >
        <activity
            android:name=".MainActivity_show_camera"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

    <supports-screens   android:resizeable="true"
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:anyDensity="true" />

    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-feature android:name="android.hardware.camera" android:required="false"/>
    <uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
    <uses-feature android:name="android.hardware.camera.front" android:required="false"/>
    <uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/>

</manifest>

最佳答案

在您的app > main > res > value > styles.xml中,确保 style name="AppTheme"存在。如果已经存在,那么清理并重建您的项目希望这会起作用。

   <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

关于java - Android Studio 在无法编辑的 XML 文件上出现 AAPT 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64508390/

相关文章:

java - 从某些示例线程代码中获取 RuntimeException

java - 小浏览器窗口中的文本框高度

java - 使用指针 parse.com 从两个类获取相同 objectid 的数据

java - 如何在Java Spring Boot中读取Resources中保存的文件

java - 添加 <mvc :annotation-driven> in applicationContext. xml 时出错

c# - 保存的 ZIP 文件损坏(从 Android 应用程序到 IIS 服务器)

Android:高级文本绘制(分栏、固定高度、分页)。如何?

java - android(Java/XML) 代码中的注释会影响 APK 的大小吗?

java - 在 Java 中创建和保存大型 XML

javascript - ChildNodes/NodeValue 混淆