我正在尝试将我的PWA网站转换为Android apk文件以在Google Play商店中分发,但无法使用Bubblewrap或PWABuilder生成apk文件。我的 PWA 的网址是 https://www.stephengarside.co.uk .
我正在运行以下命令行气泡包装init --manifest "https://www.stephengarside.co.uk/manifest.json">,我得到的错误是:
错误 https://www.stephengarside.co.uk/manifest.json 原因处的 JSON 响应正文无效:位置 0 处的 JSON 中存在意外令牌
我的清单.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设备上没有错误。谷歌灯塔也将其验证为PWA。 我在PWABuilder上遇到类似的错误。
我尝试将文件重命名为 manifest.webmanfest,并已使用 https://manifest-validator.appspot.com/验证了清单。
由于我的机器上已经安装了该应用程序的服务wroker,因此我尝试取消注册以确保不会从缓存中带来任何内容,并且还尝试以隐身方式运行pwabuilder。
任何帮助将不胜感激。
事实证明,这与我的Json文件的内容无关,而是编码。我下载了记事本++并使用UTF8编码保存了manifest.json文件,这解决了问题。您可以在本文中阅读更多内容 https://www.stephengarside.co.uk/blog/how-to-create-a-pwa-umbraco-website/