尝试按照说明通过 MS 应用中心设置推送通知。因此,我按照说明在 Firebase 控制台中创建了一个应用程序,然后从那里下载了 google-services.json 文件。将其复制到我的项目并将构建操作修复为 GoogleServicesJson。完成了 Firebase、App Center 和我的代码中的其余设置。但是当我尝试构建时,出现以下错误 -
There was an error deserializing the object of type Xamarin.GooglePlayServices.Tasks.GoogleServices
。
堆栈跟踪给了我以下信息:
There was an error deserializing the object of type Xamarin.GooglePlayServices.Tasks.GoogleServices. Encountered an unexpected character 'ï' in JSON. ---> System.Xml.XmlException: Encountered an unexpected character 'ï' in JSON.
但我在文件中的任何地方都没有看到 ï 。搜索了这个问题,发现人们使用解析器来解决这个问题,但我不确定在哪里应用所述解析器。 有人遇到过这种情况吗?
这是文件的样子
{
"project_info": {
.. Configuration info ..
},
"client": [
{
.. Lots of lines ..
}
],
"configuration_version": "1"
}
因此,我在 Visual Studio 中右键单击该文件,然后选择“十六进制编辑器”。 你瞧,
ï
是文件的第一个字符,还有左大括号之前的 >>
和 ?
:{
所以我删除了多余的字符,直到左大括号,错误就解决了。现在发现其他错误...
我有同样的错误,对我来说这是因为另一个 .cs 文件被意外选择构建为 googleservicesjson