Cordova找不到Theme.AppCompat.Light

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

我已经设置了一个简单的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>

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

FAILURE:构建因异常而失败。

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

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

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

错误:链接引用失败。

android cordova android-styles
1个回答
1
投票

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

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

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

© www.soinside.com 2019 - 2024. All rights reserved.