尝试使用自适应图标构建 cordova 应用程序时出错
Error when trying to build cordova app with adaptive icons
尝试在 config.xml 中添加自适应图标时,我在尝试构建
时遇到以下错误
One of the following attributes are set but missing the other for the density type: ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi. Please ensure that all require attributes are defined.
我的代码是:
<platform name="android">
<resource-file src="res/icon/android/colors.xml" target="/app/src/main/res/values/colors.xml" />
<icon background="@color/background" density="ldpi" foreground="res/icon/android/ldpi-foreground.png" />
<icon background="@color/background" density="mdpi" foreground="res/icon/android/mdpi-foreground.png" />
<icon background="@color/background" density="hdpi" foreground="res/icon/android/hdpi-foreground.png" />
<icon background="@color/background" density="xhdpi" foreground="res/icon/android/xhdpi-foreground.png" />
<icon background="@color/background" density="xxhdpi" foreground="res/icon/android/xxhdpi-foreground.png" />
<icon background="@color/background" density="xxxhdpi" foreground="res/icon/android/xxxhdpi-foreground.png" />
</platform>
我正在使用 cordova-android 8.0.0
在此处粘贴对同一问题(由同一开发者提出)的答案以供参考 here。
@Fmaldonado6 After some digging through the code I found that it was because I was using global cordova cordova@8.1.2, upgrading to cordova@9.0.0 via npm i -g cordova@9.0.0 fixed the problem for me. This is because even though we upgraded to cordova-android@8.0.0 in our project this library depends on information passed to it from the globally installed cordova library which it gets from cordova-common@3.1.0 whereas cordova@8.1.2 has cordova-common@2.2.5 which does not pass along foreground and background props
我有同样的错误信息,然后我意识到我使用了 scr
而不是 src
.
这个错误似乎与 src
有关,而不是 density
。
尝试在 config.xml 中添加自适应图标时,我在尝试构建
时遇到以下错误One of the following attributes are set but missing the other for the density type: ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi. Please ensure that all require attributes are defined.
我的代码是:
<platform name="android">
<resource-file src="res/icon/android/colors.xml" target="/app/src/main/res/values/colors.xml" />
<icon background="@color/background" density="ldpi" foreground="res/icon/android/ldpi-foreground.png" />
<icon background="@color/background" density="mdpi" foreground="res/icon/android/mdpi-foreground.png" />
<icon background="@color/background" density="hdpi" foreground="res/icon/android/hdpi-foreground.png" />
<icon background="@color/background" density="xhdpi" foreground="res/icon/android/xhdpi-foreground.png" />
<icon background="@color/background" density="xxhdpi" foreground="res/icon/android/xxhdpi-foreground.png" />
<icon background="@color/background" density="xxxhdpi" foreground="res/icon/android/xxxhdpi-foreground.png" />
</platform>
我正在使用 cordova-android 8.0.0
在此处粘贴对同一问题(由同一开发者提出)的答案以供参考 here。
@Fmaldonado6 After some digging through the code I found that it was because I was using global cordova cordova@8.1.2, upgrading to cordova@9.0.0 via npm i -g cordova@9.0.0 fixed the problem for me. This is because even though we upgraded to cordova-android@8.0.0 in our project this library depends on information passed to it from the globally installed cordova library which it gets from cordova-common@3.1.0 whereas cordova@8.1.2 has cordova-common@2.2.5 which does not pass along foreground and background props
我有同样的错误信息,然后我意识到我使用了 scr
而不是 src
.
这个错误似乎与 src
有关,而不是 density
。