无法安装渐进式Web应用程序网站:无图标可显示 [英] progressive web app site cannot be installed: no icon available to display

查看:103
本文介绍了无法安装渐进式Web应用程序网站:无图标可显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个渐进式Web应用程序.我从 create-react-app 开始制作样板.然后,我添加了一个Web应用清单.

I'm building a progressive web app. I started off with boilerplate from create-react-app. Then I added a web app manifest.

app/public/manifest.json

app/public/manifest.json

{
    "short_name": "First Contributions",
    "name": "First Contributions",
    "icons": [
        {
            "src": "/android-chrome-192x192.png",
            "sizes": "192x192",
            "type": "image/png"
        },
        {
            "src": "/android-chrome-256x256.png",
            "sizes": "256x256",
            "type": "image/png"
        }
    ],
    "theme_color": "#ffffff",
    "background_color": "#ffffff",
    "display": "standalone",
    "start_url": "index.html"
}

将此链接链接到index.html

app/public/index.html

app/public/index.html

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json">
    <title>First Contributions</title>
  </head>
  <body>
    <div id="root"></div>
      <script>
        if ('serviceWorker' in navigator) {
          navigator.serviceWorker.register('service-worker.js').catch(function(ex) {
            console.warn(ex);
            console.warn('(This warning can be safely ignored outside of the production build.)');
          });
        }
      </script>
    </body>
  </html>

我已经使用realfavicongenerator.net生成了图标,并将其放置在公共目录中.

I've generated icons using realfavicongenerator.net and put them in public directory.

我正在使用gh-pages部署我的应用程序.当我尝试 Add to homescreen 时,出现以下错误

I'm deploying my app using gh-pages. When I try to Add to homescreen, I get the following errors

  • android-chrome-192x192.png:1 GET https://roshanjossey.github.io/android-chrome-192x192.png 404 (Not Found)
  • Error while trying to use the following icon from the Manifest: https://roshanjossey.github.io/android-chrome-192x192.png (Download error or resource isn't a valid image)
  • Site cannot be installed: no icon available to display

我认为我在图标的Webmanifest中做错了事.

I think I'm doing something wrong in webmanifest for icons.

推荐答案

您的图标路径引用了根目录.

Your icon paths reference to the root directory.

"src": "/android-chrome-192x192.png",更改为"src": "android-chrome-192x192.png",(开头没有/).

Change "src": "/android-chrome-192x192.png", to "src": "android-chrome-192x192.png", (without / at the beginning).

这篇关于无法安装渐进式Web应用程序网站:无图标可显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆