react-native - where to put my icon picture for expo to use instead of default one?
问题描述
according to expo documentation:
The most straightforward way to provide an icon for your app is to provide the icon key in app.json
so I added my own icon to the assets folder where expo's default icons are, and modified app.json
to point to my icon:
"expo": {
...
"icon": "./assets/myIcon.png"
}
but when launching I get this error from expo:
Field: icon - cannot access file at './assets/myIcon.png
what am I missing? where should I put my Icon picture?
Solved
by running expo start -c
to clear cache.
*Note: it took me a few minutes to sync with my expo client app!
解决方案
根据我与问题海报(@Blue Turtle)的对话,我从中得到了一些收获。
图像尺寸
确保您用于图标的图像必须是完美的正方形,这一点很重要。如果不是 Expo 会给出类似下面的错误
Error: Problems validating asset fields in app.json. See https://docs.expo.io/
• Field: icon - image should be square, but the file at './assets/icon.png' has dimensions 1242x2436.
文档建议您使用大小为1024x1024
https://docs.expo.io/versions/latest/workflow/configuration/#icon的图像
用于应用图标的图像的本地路径或远程 URL。我们建议您使用 1024x1024 png 文件。该图标将出现在主屏幕和 Expo 应用程序中。
清除缓存
此外,在更新资产等时,建议关闭并重新启动捆绑程序,使用以下命令重新启动expo start -c
。以这种方式启动捆绑器将确保您的缓存被清除,并且您对包、资产等所做的任何更改都将被进行,并且您希望遇到的错误更少。
推荐阅读
- java - java - 如何从catch块转到java中的try块?
- active-directory - Azure AD 多租户应用程序不可预测的行为?
- cron - 在 cron 中转义哈希 (#)
- php - 如果它们共享相同的ID,则将它们附加在一起
- apache-spark - Spark DataFrame:加入卡在同一阶段
- ios - 在进行分页时,新数据已添加到 tableview 时间 tableview 滚动在 IOS swift 中跳跃
- c# - 如何检查代码是否在任何平台上的 Unity 中运行
- python - 将工作表名称更改为重复的列值
- c++ - Qt 软件在 USB 事件上崩溃,例如 USB 设备插入或鼠标移动
- php - Laravel 在单独的域和子域中共享会话