问题
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
回答1:
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')" />
回答2:
Even after installing "Xamarin.GooglePlayServices.Basement" GoogleServiceJson option was not showing. Surprisingly but when i quit Xamarin studio and opened it again it starts displaying.
回答3:
1-Download first these Packages:
Xamarin.Firebase.Common
Xamarin.Firebase.Config
Xamarin.Firebase.Iid
Xamarin.GooglePlayServices.Base
Xamarin.GooglePlayServices.Basement
Xamarin.GooglePlayServices.Tasks
2-then restart and rebuild
3-from google-services.json --> Properties --> build Action: GoogleServicesJson
回答4:
In Visual Studio close the Project and reopen it. That worked for me:)
回答5:
Download first these Packages:
then restart
回答6:
GoogleServiceJsom is coming from Xamarin.GooglePlayServices.Basement package. If it is not visible after the package installation restart your visual studio project, it will work
回答7:
I thougt i was doing it wrong but you dont get the Build action by rightklick it like a example from Mac
PS You dont right klick on the Google-Services.json and see the Build avtion You press properties and then at the properties you find the Build action
回答8:
While using AppCenter, I was not adding App centre and App Center Push packages to Android Dependencies folder. Upon adding GoogleServicesJson immediately showed up
回答9:
I was getting stuck with this because the Microsoft guide https://docs.microsoft.com/en-us/xamarin/android/data-cloud/google-messaging/remote-notifications-with-fcm?tabs=windows which was saying to install Xamarin.GooglePlayServices.Base directly.
What worked: install Xamarin.GooglePlayServices.Gcm through Nuget
来源:https://stackoverflow.com/questions/42677766/cant-set-build-action-to-googleservicejson