【问题标题】:Install a manifest.json on android在 android 上安装 manifest.json
【发布时间】:2018-10-30 22:34:45
【问题描述】:

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

  • 用于安装和提示访问权限的 manifest.json
  • 用于离线缓存的服务工作者。 (它已正确安装,但由于某种原因从未接听离线电话)

以下 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++在第一个括号前自动加空格

【问题讨论】:

    标签: javascript android notepad++ manifest


    【解决方案1】:

    根据MDN docs on installable pwa

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

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

    【讨论】:

      【解决方案2】:

      是编辑器:即使保存为 utf-8,记事本也会在第一个括号“{”之前添加一个空格,从而使代码无效。谨慎选择 JSON 编辑器!

      【讨论】:

      • 这听起来像是用户错误,而不是 Notepad++ 的错误。如果 Notepad++ 添加了意外的空格,那么就会发出许多错误报告。您能否提供有关如何重现该问题的详细信息。
      猜你喜欢
      • 2016-08-26
      • 1970-01-01
      • 1970-01-01
      • 2013-07-31
      • 2011-02-13
      • 2016-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多