无法将Build Action设置为GoogleServiceJson

oce*_*kit 12 push-notification xamarin.android xamarin google-play-services

我正在使用Xamarin-Android制作一个应用程序,所以我需要将Build Action设置为我的google-services.json文件,但是没有像GoogleServicesJson那样的属性,当我尝试写它时,它会显示给我一个例外:

抛出了类型'System.Runtime.InteropServices.ExternalException'的异常.

我试图保存然后重新启动Visual Studio,但它没有解决问题.

如果您知道如何解决这个问题,请帮助我!:)
那是我点击的文件

Sus*_*ver 24

GoogleServicesJson生成类型来自于Xamarin.GooglePlayServices.Basement.targets.

如果您的项目没有Xamarin.GooglePlayServices.Basement通过其中一个家属安装,通常Xamarin.GooglePlayServices.Gcm或者Xamarin.Firebase.Messaging如果我们正在谈论消息传递,那么您将无法使用该构建操作.

添加安装Basement的软件包或自行手动添加后,您.csproj将包含导入,Xamarin.GooglePlayServices.Basement.targets并将GoogleServicesJson作为构建类型提供:

.csproj 导入示例:

  <Import Project="..\packages\Xamarin.GooglePlayServices.Basement.42.1001.0\build\MonoAndroid70\Xamarin.GooglePlayServices.Basement.targets" Condition="Exists('..\packages\Xamarin.GooglePlayServices.Basement.42.1001.0\build\MonoAndroid70\Xamarin.GooglePlayServices.Basement.targets')" />
Run Code Online (Sandbox Code Playgroud)

  • 如果安装后没有看到它,只需重新启动 Visual Studio 即可。 (2认同)

Ven*_*ari 14

即使在安装"Xamarin.GooglePlayServices.Basement"后,GoogleServiceJson选项也未显示.令人惊讶的是,当我退出Xamarin工作室并再次打开它时,它开始显示.

  • 我没有关闭IDE(Visual Studio for Mac),我只需要关闭并重新打开解决方案. (2认同)

Sul*_*zat 6

1 - 首先下载这些包:

Xamarin.Firebase.Common

Xamarin.Firebase.Config

Xamarin.Firebase.Iid

Xamarin.GooglePlayServices.Base

Xamarin.GooglePlayServices.Basement

Xamarin.GooglePlayServices.Tasks
Run Code Online (Sandbox Code Playgroud)

2 - 然后重新启动并重建3 - 来自google-services.json - >属性 - >构建操作:GoogleServicesJson