我在哪里可以在xamarin应用程序中添加google-services.json

puk*_*uko 13 c# xamarin.android xamarin google-play-services

您好我们正在开发Xamarin应用程序,我们希望监视有多少人从我们的推荐ID安装应用程序.

我找到此文档https://developers.google.com/analytics/devguides/collection/android/v4/ ,其中显示"将刚刚下载的google-services.json文件复制到Android的app /或mobile /目录中工作室项目."

我有visual studio(2013)项目当然缺少这些文件夹.问题是,我在visual studio项目中添加了google-services.json文件?

提前致谢

sno*_*yak 17

我不知道什么时候有必要,但正如我发布的那样(2017年5月),这是必要的.我把它放在我的Android .csproj文件所在的目录中.然后我将它添加到项目中并确保它Xamarin.GooglePlayServices.Base.targets在我的项目中.csproj.我读到重建将足以使正确的构建操作出现,但构建和重新启动XS对我来说就是这样.我的最终结果.csproj是这样的:

<ItemGroup>
    <GoogleServicesJson Include="google-services.json" />
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)

  • 嗨,是否可以通过在`.csproj`中使用`Condition`语句来拥有多个`GoogleServicesJson``StartGroup`? (3认同)

Kas*_*chi 13

  1. 使用文件资源管理器转到您的解决方案并复制 Droid 文件夹中的 google-services.json。
  2. 打开 Visual Studio 并转到解决方案资源管理器。
  3. 右键单击 Droid 项目 -> 添加 -> 现有项目,然后从文件浏览中选择 google-services.json(它会将 google-services.json 添加到解决方案中)。
  4. 右键单击 google-services.json 并转到属性。
  5. 在 Properties 窗格中,将 Build Action 设置为 GoogleServicesJson。


MSFT 文档中的一个示例:https : //docs.microsoft.com/en-us/appcenter/sdk/push/migration/xamarin-android#3-google-servicesjson

  • @niico 通过 Nuget 将 Xamarin.GooglePlayServices.Base 添加到您的项目,然后重新加载您的项目。然后它应该显示 (4认同)

小智 5

为了选择将构建操作设置为 GoogleServicesJson,您应该首先通过 Nuget 安装 Xamarin.GooglePlayServices.Base。然后关闭VS并重新打开。