我正在尝试在 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/