错误:为 ionic 构建时,android 图标 png 的源路径不存在 [英] Error: Source Path does not exist for android icon png when building for ionic
问题描述
Your system information:
Cordova CLI: 6.5.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
OS: macOS Sierra
Node Version: v6.9.5
Xcode version: Xcode 8.2.1 Build version 8C1002
我正在尝试使用 ionic platform add android
来创建一个 android 项目,但它总是抱怨 resources/android/icon/drawable-hdpi-icon.png
不存在.事实上它不存在——这些资源都不存在.它们可以通过 ionic resources
创建.
I am trying to use ionic platform add android
to create an android project, but it always complains that resources/android/icon/drawable-hdpi-icon.png
does not exist. In fact it doesn't -- none of these resources exist. They can get created by ionic resources
.
但是如果我尝试在没有平台的情况下运行 ionic resources
,我会被告知首先添加平台.这使我基本上做如下事情:
However if I try to run ionic resources
without the platform, I am told to add the platform first. This leads me to essentially do something like:
ionic platform add android
ionic resources
ionic platform rm android
ionic platform add android
然后它可以正常工作.我可以做些什么来确保在添加平台之前正确构建或引用资源?
Then it works properly. Is there anything I can do to make sure the resources get properly built or referenced before adding the platform?
推荐答案
这实际上与我的配置有关.如果您没有在配置中指定平台,platform add
将为您创建一个.这会自动包含可能不存在的资源的路径.
This actually had to do with my configuration. If you don't specify the platform in your configuration, platform add
will create one for you. This automatically includes paths to resources that may not be there.
更新您的 config.xml 以包含平台;即使它是空的:
Update your config.xml to include the platform; even if it is empty:
<platform name="android"/>
<platform name="ios"/>
然后,platform add
将不会更新配置中的平台并查找可能不存在的资源.尽管如此,您仍然应该使用ionic resources
来生成它们.
Then, platform add
will not update the platform in the config and look for resources that may not be there. You still should do ionic resources
to generate them after the fact, though.
这篇关于错误:为 ionic 构建时,android 图标 png 的源路径不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!