android - Cordova 找不到 Theme.AppCompat.Light

标签 android cordova android-styles

我已经建立了一个简单的 Cordova 项目,它应该在 Android 上显示启动画面。要利用整个屏幕,我需要通过扩展 Theme.AppCompat.Light 来摆脱状态栏。 所以我设置了这个 styles.xml 文件并将其放入 Cordova 项目的根文件夹中。

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Full" parent="@style/Theme.AppCompat.Light">
    <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>
</resources>

Cordova的config.xml文件是这样的:

    <?xml version='1.0' encoding='utf-8'?>
<widget id="com.domain.test" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Test</name>
    <description>
        Just a test
    </description>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <access origin="*" />
    <preference name="Fullscreen" value="true" />
    <preference name="Orientation" value="landscape" />
    <splash src="res/screen/android/splashScreen.png" />
    <preference name="SplashMaintainAspectRatio" value="true" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
        <icon density="mdpi" src="res/icon/android/mdpi.png" />
        <icon density="hdpi" src="res/icon/android/hdpi.png" />
        <icon density="xhdpi" src="res/icon/android/xhdpi.png" />
        <icon density="xxhdpi" src="res/icon/android/xxhdpi.png" />
        <icon density="xxxhdpi" src="res/icon/android/xxxhdpi.png" />
        <resource-file src="styles.xml" target="app/src/main/res/values/styles.xml" />
    </platform>
    <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application/activity">
        <activity android:label="@string/app_name" android:name=".ActivityName" android:theme="@style/Full" />
    </edit-config>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
    <plugin name="cordova-plugin-fullscreen" spec="^1.2.0" />
    <engine name="android" spec="~7.1.4" />
</widget>

如果我尝试编译该项目,我会收到以下错误:

失败:构建失败并出现异常。

出了什么问题: 任务“:app:processDebugResources”执行失败。 无法执行 aapt

1 秒内构建失败 cmd:命令失败,退出代码为 1 错误输出:

错误:找不到资源样式/Theme.AppCompat.Light(又名 com.domain.test:style/Theme.AppCompat.Light)。

错误:链接引用失败。

最佳答案

您可能没有将 AppCompat 库添加到您的项目中。您是否将以下行添加到您的配置文件中?

<framework src="com.android.support:appcompat-v7:+"/>

在此处阅读有关框架的更多信息:https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html

关于android - Cordova 找不到 Theme.AppCompat.Light,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54573276/

相关文章:

android - ArrayList的高效onDraw

android - 你将如何编写一个在 android 上使用的库?

javascript - 如何为日期时间本地输入类型指定特定范围?

java - AppCompat SupportActionBar 有关图像放置的问题

android - Android 6 中的滚动条触摸区域

android - 带有背景颜色选择器的按钮 - 单击时背景颜色从按钮中延伸出来

java - 布局底部有两个按钮的 ScrollView

android - 用于检测应用程序启动的广播接收器

android - 错误 : Multiple dex files define Landroid/support/annotations/AnimRes with Admob and Facebook Cordova plugins

javascript - 为什么我的 Cordova 应用程序的字体在 Windows Phone 8.1 设备上非常小?