首页 > 解决方案 > 在 android 上安装 manifest.json

问题描述

我正在尝试在这里构建一个渐进式 Web 应用程序:https ://121eddie.github.io 。这涉及

以下 manifest.json 已通过https://manifest-validator.appspot.com/验证。

{
"name": "Determiner ma position et la partager",
"short_name": "PositionWeb",
"start_url": "/index.html",
"homepage_url":"https://121eddie.github.io/",
"display": "standalone",
"description": "Une application Web Progressive qui permet de connaitre sa position et de la telecharger ou partager, meme en mode offline",
"lang": "fr-FR",
"scope": "/",
"background_color": "lightyellow",
"theme_color": "lightgreen",
"permissions": [
    "geolocation",
    "fileSystem",
    "fileSystem.write",
    "notifications"
],
"icons": [{"src": "icon200.png","sizes": "200x200","type": "image/png"},
{"src": "icon512.png","sizes": "512x512","type": "image/png"}
]
}

它在 index.html 中加载

 <link rel="manifest" href="manifest.json">

然而在谷歌浏览器上我得到了

SytaxError: unexpected token in JSON on position 0

错误在哪里?


更新

我改进了以下几个方面

  1. 我添加了一个图标
  2. 我用 utf-8 编码(而不是 ansi)
  3. 我添加了一个 favicon.ico

解决方案

防止 Notepad++ 在第一个括号前自动添加空格

标签: javascriptandroidnotepad++manifest

解决方案


根据MDN docs on installable pwa

Web 清单的最低要求是名称和至少一个图标(带有 src、大小和类型)。

所以,至少你的清单没有图标


推荐阅读