Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS 2022 Maui is does not give the option for the GoogleServiceJson build action #14486

Closed
philm001 opened this issue Apr 10, 2023 · 11 comments
Closed
Labels
area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging platform/android 🤖 s/move-to-vs-feedback Tells automation to ask the person to use VS Feedback to report the issue s/needs-attention Issue has more information and needs another look t/bug Something isn't working

Comments

@philm001
Copy link

Description

I downloaded the following nuget packages:

Firebase.common
Firebase.Messaging
GoogleplayServices.Base
GoogleplayServices.Basement
GoogleplayServices.Tasks

I have restarted VS 2022 multiple times. When I import the google-services.json file under the Android platform folder and when I go to Properties->Build Action. There is no option for GoogleServicesJson.

Steps to Reproduce

See above

Link to public reproduction project repository

n/a

Version with bug

6.0.312

Last version that worked well

6.0.312

Affected platforms

Android

Affected platform versions

Latest version of Android

Did you find any workaround?

A workaround has been discovered:

See this link here:

https://developercommunity.visualstudio.com/t/googleservicesjson-build-action-is-not-available/294192?viewtype=solutions

Here is the description of the work around:

Unfortunately, sometimes including the Xamarin.GooglePlayservices.Basement Nuget Package, cleaning, and restarting Visual Studio doesn't result in the necessary update to the projects csproj file. In this case its easiest to update the csproj file manually in a text editor (obviously after having tried the above!):

replacing "YOUR_PROJECT_PATH\packages\Xamarin.GooglePlayServices.Basement.60.1142.1\build\MonoAndroid80" with the correct relative path to the location of the package within your solution. Take a look at other import statements in csproj to get an idea of the correct relative path and verify the location with File Explorer (in case the dlls are stored under a different project in your solution).

Note that this comment is from 2019. So the version numbers will be higher. But the idea is the same. In the project file, you need to manually point to the targets file that is inside of the Xamarin.GooglePlayServices.Basement package in order to get this to work.

Relevant log output

No response

@philm001 philm001 added the t/bug Something isn't working label Apr 10, 2023
@jsuarezruiz jsuarezruiz added area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging s/move-to-vs-feedback Tells automation to ask the person to use VS Feedback to report the issue labels Apr 10, 2023
@ghost
Copy link

ghost commented Apr 10, 2023

Thanks for the issue report @philm001! This issue appears to be a problem with Visual Studio, so we ask that you use the VS feedback tool to report the issue. That way it will get to the routed to the team that owns this experience in VS.

If you encounter a problem with Visual Studio, we want to know about it so that we can diagnose and fix it. By using the Report a Problem tool, you can collect detailed information about the problem, and send it to Microsoft with just a few button clicks.

  1. Go to the Visual Studio for Windows feedback tool or Visual Studio for Mac feedback tool to report the issue
  2. Close this bug, and consider adding a link to the VS Feedback issue so that others can follow its activity there.

@jonpryor
Copy link
Member

@philm001: you mention that you "downloaded" GoogleplayServices.Basement and other packages. What does "downloaded" mean here? Used "Manage NuGet Packages…" within Visual Studio, resulting in a <PackageReference/> within the .csproj? What <PackageReference/>s does your .csproj have?

Part of the problem may be that nuget.org has three "GoogleplayServices.Basement" packages:

Which of these packages did you add?

The one you need to add is Xamarin.GooglePlayServices.Basement, which contains a build/net6.0-android31.0/Xamarin.GooglePlayServices.Basement.targets, which in turn contains:

<ItemGroup>
  <AvailableItemName Include="GoogleServicesJson" />
</ItemGroup>

which is what Visual Studio uses to populate the Build action options.

When I use Visual Studio 17.5.4, create a new .NET Android project, and add the Xamarin.GooglePlayServices.Basement NuGet package, I then see the GoogleServicesJson build action within the File Properties panel. (This appeared to require reloading the project for a Classic Xamarin.Android app, but a .NET Android project did not require reloading. This may be because I created the Xamarin.Android project first and reloaded the solution while trying to repro this.)

@jonpryor jonpryor added the s/needs-info Issue needs more info from the author label Apr 26, 2023
@ghost
Copy link

ghost commented Apr 26, 2023

Hi @philm001. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@ghost ghost added the s/no-recent-activity Issue has had no recent activity label May 1, 2023
@ghost
Copy link

ghost commented May 1, 2023

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@philm001
Copy link
Author

philm001 commented May 1, 2023

@philm001: you mention that you "downloaded" GoogleplayServices.Basement and other packages. What does "downloaded" mean here? Used "Manage NuGet Packages…" within Visual Studio, resulting in a <PackageReference/> within the .csproj? What <PackageReference/>s does your .csproj have?

Part of the problem may be that nuget.org has three "GoogleplayServices.Basement" packages:

* [GooglePlayServices.Basement](https://www.nuget.org/packages/GooglePlayServices.Basement), published by [Vinayaka-Hebbar](https://www.nuget.org/profiles/Vinayaka-Hebbar) and last updated in _2019_.

* [Xamarin.GooglePlayServices.Basement](https://www.nuget.org/packages/Xamarin.GooglePlayServices.Basement), published by [Microsoft](https://www.nuget.org/profiles/Microsoft) [Xamarin](https://www.nuget.org/profiles/Xamarin), and last updated in January 2023.

* [Crosslight.Xamarin.GooglePlayServices.Basement](https://www.nuget.org/packages/Crosslight.Xamarin.GooglePlayServices.Basement), published by [intersoftsolutions](https://www.nuget.org/profiles/intersoftsolutions), and last updated in _2018_.

Which of these packages did you add?

The one you need to add is Xamarin.GooglePlayServices.Basement, which contains a build/net6.0-android31.0/Xamarin.GooglePlayServices.Basement.targets, which in turn contains:

<ItemGroup>
  <AvailableItemName Include="GoogleServicesJson" />
</ItemGroup>

which is what Visual Studio uses to populate the Build action options.

When I use Visual Studio 17.5.4, create a new .NET Android project, and add the Xamarin.GooglePlayServices.Basement NuGet package, I then see the GoogleServicesJson build action within the File Properties panel. (This appeared to require reloading the project for a Classic Xamarin.Android app, but a .NET Android project did not require reloading. This may be because I created the Xamarin.Android project first and reloaded the solution while trying to repro this.)

So this here is my current NuGet packages that I have added. I downloaded them through the NuGet Package manager

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0-android33.0'">
	  <PackageReference Include="Xamarin.Firebase.Common">
	    <Version>120.2.0.1</Version>
	  </PackageReference>
	  <PackageReference Include="Xamarin.Firebase.Messaging">
	    <Version>123.1.1.1</Version>
	  </PackageReference>
	  <PackageReference Include="Xamarin.Google.Dagger">
	    <Version>2.44.2.1</Version>
	  </PackageReference>
	  <PackageReference Include="Xamarin.GooglePlayServices.Base">
	    <Version>118.1.0.1</Version>
	  </PackageReference>
	  <PackageReference Include="Xamarin.GooglePlayServices.Basement">
	    <Version>118.1.0.2</Version>
	  </PackageReference>
	  <PackageReference Include="Xamarin.GooglePlayServices.Tasks">
	    <Version>118.0.2.1</Version>
	  </PackageReference>
	</ItemGroup>

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author s/no-recent-activity Issue has had no recent activity labels May 1, 2023
@juniorsaraviao
Copy link

I continue seeing this issue targeting net7.0-android33.0 and GoogleServicesJson doesn't appear.
If I target net7.0-android or net6.0-android, the GoogleServicesJson appears.

@bryansjenks
Copy link

Targeting net7.0-android33.0, I have the issue as well.

I'm adding Shiny.Push.AzureNotificationHubs to get Xamarin.GooglePlayServices.Basement (probably there were other ways to do this - maybe I could even have added Xamarin.GooglePlayServices.Basement directly).
I had to add the google-services.json file to the project, then manually edit the .csproj file to add

<ItemGroup>
    <GoogleServicesJson Include="google-services.json" />
</ItemGroup>

and it does seem to be initializing play services now, but neither the GoogleServiceJson build action, nor the google-services.json file shows up in my solution at this point. (all that matters is that it's working though)

@nysand
Copy link

nysand commented Oct 31, 2023

I had the same problem and had to delete my project clone it again install Xamarin.GooglePlayServices.Base and then I was able to see the GoogleServiceJson build action. Working with VS22 17.4.7

@philm001
Copy link
Author

philm001 commented Nov 5, 2023

@bryansjenks

I actually got mine to work somehow. I forgot what I did but just want to confirm that adding that specific item group, everything is working for you now?

@jfversluis
Copy link
Member

Even though you might not see it in Visual Studio, if you install the Xamarin.GooglePlayServices.Basement package (through Shiny or not) it will be there and you can manually add that through your csproj. As indicated before, this is ultimately seemingly a tooling issue. If you want to have that resolved, please report it through the process outlined above. Thanks!

@jfversluis jfversluis closed this as not planned Won't fix, can't repro, duplicate, stale Jan 15, 2024
@bryansjenks
Copy link

@philm001 Yes, I ended up just editing the .csproj file to set the build action.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging platform/android 🤖 s/move-to-vs-feedback Tells automation to ask the person to use VS Feedback to report the issue s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants