Search code examples
xamarinpush-notificationxamarin.androidgoogle-play-services

Can't set Build Action to GoogleServiceJson


I'm working with Xamarin-Android to make an application, so I need to set Build Action to my google-services.json file but there is no such Property as GoogleServicesJson, and when I try just to write it, it shows me an exception:

Exception of type 'System.Runtime.InteropServices.ExternalException' was thrown.

I tried to save and then restart Visual Studio, but it didn't solve the problem.

If you know how to solve this problem, please help me! :)
That's the file I'm clicking on


Solution

  • The GoogleServicesJson build type comes from the Xamarin.GooglePlayServices.Basement.targets.

    If your project does not have Xamarin.GooglePlayServices.Basement installed via one of its dependents, usually Xamarin.GooglePlayServices.Gcm or Xamarin.Firebase.Messaging if we are talking about messaging, then you will not have that build action available.

    After adding a package that installs Basement, or manually adding it yourself, your .csproj will contain an import for Xamarin.GooglePlayServices.Basement.targets and GoogleServicesJson will be available as a build type:

    .csproj import example:

      <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')" />