0

我正在尝试将我的 PWA 网站转换为 Android apk 文件以在 Google Play 商店中分发,但无法使用 Bubblewrap 或 PWABuilder 生成 apk 文件。我的 PWA 的网址是https://www.stephengarside.co.uk

我正在运行以下命令行bubblewrap init --manifest "https://www.stephengarside.co.uk/manifest.json"我得到的错误是:

错误在https://www.stephengarside.co.uk/manifest.json处的 json 响应正文无效原因:JSON 中位置 0 的意外令牌

我的 manifest.json 文件是:

{
  "start_url": "/",
  "description": "The SG Digital app provides free articles on the latest web software development techniques including chatbots, VR and AR, progressive web apps and voice apps for smart speakers and displays.",
  "short_name": "SG Digital",
  "name": "SG Digital Web Development",
  "display": "standalone",
  "orientation": "any",
  "lang": "English",
  "scope": "/",
  "background_color": "#000",
  "theme_color": "#000",
  "icons": [
    {
      "src": "images/icons/icon-72x72.png",
      "sizes": "72x72",
      "type": "image/png",
      "purpose": "any maskable"
    },
    {
      "src": "images/icons/icon-96x96.png",
      "sizes": "96x96",
      "type": "image/png",
      "purpose": "any maskable"
    },
    {
      "src": "images/icons/icon-120x120.png",
      "sizes": "120x120",
      "type": "image/png",
      "purpose": "any maskable"
    },
    {
      "src": "images/icons/icon-128x128.png",
      "sizes": "128x128",
      "type": "image/png",
      "purpose": "any maskable"
    },
    {
      "src": "images/icons/icon-144x144.png",
      "sizes": "144x144",
      "type": "image/png",
      "purpose": "any maskable"
    },
    {
      "src": "images/icons/icon-152x152.png",
      "sizes": "152x152",
      "type": "image/png",
      "purpose": "any maskable"
    },
    {
      "src": "images/icons/icon-180x180.png",
      "sizes": "180x180",
      "type": "image/png",
      "purpose": "any maskable"
    },
    {
      "src": "images/icons/icon-192x192.png",
      "sizes": "192x192",
      "type": "image/png",
      "purpose": "any maskable"
    },
    {
      "src": "images/icons/icon-384x384.png",
      "sizes": "384x384",
      "type": "image/png",
      "purpose": "any maskable"
    },
    {
      "src": "images/icons/icon-512x512.png",
      "sizes": "512x512",
      "type": "image/png",
      "purpose": "any maskable"
    }
  ],
  "screenshots": [
    {
      "src": "images/screenshots/screenshot1.jpg",
      "sizes": "1280x720",
      "type": "image/jpg"
    },
    {
      "src": "images/screenshots/screenshot2.jpg",
      "sizes": "1280x720",
      "type": "image/jpg"
    }
  ]
}

我的 PWA 工作正常,我可以在 Windows 或 Android 设备上安装它并且没有错误。Google Lighthouse 也将其验证为 PWA。我在使用 PWABuilder 时遇到了类似的错误。

我已尝试将文件重命名为 manifest.webmanfest,已使用https://manifest-validator.appspot.com/验证了清单。

由于我的机器上已经安装了应用程序的服务程序,因此我尝试取消注册以确保没有从缓存中获取任何内容,并尝试在隐身模式下运行 pwabuilder。

任何帮助将非常感激。

4

1 回答 1

0

原来这与我的 Json 文件的内容无关,它是编码。我下载了notepad++并用UTF8编码保存了manifest.json文件,这就解决了这个问题。您可以在这篇文章中阅读更多内容https://www.stephengarside.co.uk/blog/how-to-create-a-pwa-umbraco-website/

于 2020-07-03T07:30:34.133 回答