Googleplayservicescomponents: Deprecation notice: Google Play Services version of the Places SDK for Android

Created on 25 Feb 2019  路  41Comments  路  Source: xamarin/GooglePlayServicesComponents

Xamarin.Android

Google Play Services Version (16.0.0):

Describe your Issue:

This is likely not the right place for this, but is there any word on how the deprecation of the Google Play Services version of the Places SDK for Android will affect this library? Google has a migration guide available that says services will be disabled on July 29, 2019 (https://developers.google.com/places/android-sdk/client-migration), and that everyone should move to the new client library starting January 29, 2019. However, I can't find any information online regarding new Xamarin packages.

VS bug #805953

azdo-sync in-progress

Most helpful comment

Started preparing bindings.

All 41 comments

After looking into this further, it appears the bindings for the Places SDK are no longer working for new apps*. Attempting to run the sample solution returns the status: PLACES_API_ACCESS_NOT_CONFIGURED. I'm assuming this is because the Places SDK for Android and Places SDK for iOS services have been deprecated and consolidated into a single Places API service. This means they no longer show up in the Google API Console and cannot be enabled; which means a valid API key can't be configured. The new Places API service is meant to be used with the new SDK client library; so enabling it does not work for the current bindings.

*If you previously had Places SDK for Android/iOS enabled in the Google API Console prior to January 29, 2019; then I believe the bindings will continue to work until July 29, 2019. It sounds like Google has left these services enabled during the migration period; they just can't be enabled for new projects.

Steps to Reproduce (with link to sample solution if possible):

Attempt to run the sample solution with an API key generated for a brand new project.

Sorry, we don't currently have bindings for the newer replacement libraries, though it's certainly possible to create your own bindings for them.

We'll put it on the roadmap but I can't give you any sort of date we'll have them for.

How can one create bindings for the Places API

@jmetcal4

Attempt to run the sample solution with an API key generated for a brand new project.

Can you provide link to minimal sample so I can try to reproduce this. I'm not sure if ican get API key and this we can discuss in private.

@moljac

It should be enough to use the GooglePlayServicesComponents sample from here:

https://github.com/xamarin/GooglePlayServicesComponents/tree/master/samples/com.google.android.gms/play-services-places

Any updates on this?

Old Places SDK will stop working from end of July this year. What's the plan for support the replacement?

Sorry, we don't currently have bindings for the newer replacement libraries, though it's certainly possible to create your own bindings for them.

We'll put it on the roadmap but I can't give you any sort of date we'll have them for.

When on the road map is this going to get started? I'm attempting to do them myself, but am having a lot of issues. I'm wasting a lot of time trying to replace this before the cut-off date instead of working on new features.

If the team has anything started and is willing to share, I can at least work off of a best practice example and go from there. I'd even be willing to submit a PR if I can get it working, but doing this from scratch myself is taking much more effort that has delayed my roadmap for my app.

Started preparing bindings.

@moljac how's it going? I decided to have a go at binding the Compatibility library since I've got code using the old API. This is my first attempt at generating a binding and it has been slow. I've got the .aar and created the binding project. First build resulted in 130 warnings (many of which I'm guessing are really errors). I've got a bunch of these "The member 'AutocompleteFilter.Builder.class_ref' does not hide an accessible member. The new keyword is not required." for the C# code and then a bunch of warnings coming from the BINDINGSGENERATOR e.g. warning BG8604: top ancestor Place not found for nested type Com.Google.Android.Libraries.Places.Compat.Place.IPlaceType. I guess the BINDINGSGENERATOR ones I need to fix with the transforms? If you've got an good advice on how to go about this or links then any help would be gratefully received. Good luck by the way!

@suggyd

NOTE: bindings are close to be done. I don't know the status to the last detail, because I was not working on those. We split the load and other teammate got the honor to do these.

This is my first attempt at generating a binding and it has been slow. I've got the .aar and created the binding project.

Being slow - is normal. It is like walking, sports, everything - you'll need practice.

First build resulted in 130 warnings (many of which I'm guessing are really errors). I've got a bunch of these "The member 'AutocompleteFilter.Builder.class_ref' does not hide an accessible member.

This is because of differences in java and c# idioms.

The new keyword is not required." for the C# code and then a bunch of warnings coming from the BINDINGSGENERATOR e.g. warning BG8604: top ancestor Place not found for nested type Com.Google.Android.Libraries.Places.Compat.Place.IPlaceType. I guess the BINDINGSGENERATOR ones I need to fix with the transforms?

Those indicate that Place class was not surfaced and now you must find the reason why. (Could be bunch of reasons - just as warning)

If you've got an good advice on how to go about this or links then any help would be gratefully received.

Due to the fact that the bindings are close to be finished - i would suggest you - try some simpler ones - we have huge list piling behind our backs. This said - only if you have wish/desrire/urge to learn bindings.

Good luck by the way!

Thanks. But what for? We do that all the time, so luck must be excluded from the equation.
cheers

Thanks @moljac I think I've made some progress! Having sorted out (hopefully) field / property collisions and return types, it is now just 1 thing stopping me (feeling hopeful) from building. I have an obfuscated interface method that I can't actually see being implemented on the class claiming to implement it? I have two occurrence of this exact same problem. I'm not a Java expert but I don't see it being b() being implemented? Could Object be implementing it and I'm missing that?

The problem interface:

package com.google.android.libraries.places.internal;
public interface pt {
T b();
}

The class implementing it:

package com.google.android.libraries.places.internal;
public class hq extends Object implements pt {
public hq() { this.a = new Intent(); } public final Intent a;
public void a(String paramString1, @Nullable String paramString2) {
if (paramString2 != null) {
this.a.putExtra(paramString1, paramString2); return;
} this.a.removeExtra(paramString1);
} public void a(String paramString, @Nullable Parcelable paramParcelable) {
if (paramParcelable != null) {
this.a.putExtra(paramString, paramParcelable); return;
} this.a.removeExtra(paramString);
} public void a(String paramString, @Nullable Serializable paramSerializable) {
if (paramSerializable != null) {
this.a.putExtra(paramString, paramSerializable); return;
} this.a.removeExtra(paramString);
} public Intent a(Context paramContext, Class paramClass) {
this.a.setClass(paramContext, paramClass);
Resources.Theme theme = paramContext.getTheme();
TypedValue typedValue1 = new TypedValue();
TypedValue typedValue2 = new TypedValue();
if (theme.resolveAttribute(16843827, typedValue1, true) &&
!this.a.hasExtra("primary_color"))
this.a.putExtra("primary_color", typedValue1.data);
if (theme.resolveAttribute(16843828, typedValue2, true) &&
!this.a.hasExtra("primary_color_dark"))
this.a.putExtra("primary_color_dark", typedValue2.data);
return this.a;
}
}

The .net error:

error CS0535: 'Hq' does not implement interface member 'IPt.B()'

@suggyd

Note: written from top of my head, but you'll get the idea:

Quick and Dirty:

<remove-node
    path="/api/package[@name="A"]/class[@name='hq']/imlpements[@name='pt']"
    >
</remove-node

Got it?
If not - XamarinComponents gitter channel, mention @moljac and I should be pinged in slack

Hi guys! Just letting you know that the new Google Places for Android binding is finally bound and in a PR here. Just, we are making a quick sample to make sure that everything is working properly.

Sorry for the delay on bringing this to you!

Best!

Guys! Just letting you know that Google Places for Android is live now on NuGet!

Best!

Guys! Just letting you know that Google Places for Android is live now on NuGet!

Best!

Thank you! I was able to get bindings on my own after a sizeable effort, but it added several MB to my *.apk. I'm sure it was the way I dealt with the dependencies. However, I'll try this nuget package though and provide feedback if I run into any issues. I'll probably be sometime this weekend. Thanks for the effort!

Guys! Just letting you know that Google Places for Android is live now on NuGet!

Best!

Thanks for your efforts, but it crashes for me at PlacesApi.CreateClient(Application.Context)
A lot of dependencies seem to be missing

Guys! Just letting you know that Google Places for Android is live now on NuGet!
Best!

Thanks for your efforts, but it crashes for me at PlacesApi.CreateClient(Application.Context)
A lot of dependencies seem to be missing

I think the correct implementation according to Google Documentation should be

PlacesApi.Initialize(Application.Context, "YOUR API KEY")

Well yes I did that one line above, Do the bindings work for you?

@Elatech
Please do not be so picky. Let us bind and test bindings 1st, then we can make API adorable.

@tipa

Any more info?
"It crashes" (we do feel your pain), but that does not help us.

Nice Job so far @moljac.
I have implemented the API.
I tried using the Autocomplete Activity;

after the StartActivityForResult(Intent, requestCode) call, the app crashed.

The response was ->
Java.Lang.NoClassDefFoundError:

@Elatech Thanks, but it was not me, but @SotoiGhost

We'll check the issue.

Minimal repro sample? Maybe?

Cheers to @SotoiGhost . You rock

Here is a snippet of my implementation

`void InitPlaces()
    {
        if (!PlacesApi.IsInitialized)
        {
            PlacesApi.Initialize(this, "MY API KEY");
        }
    }

    private void DisplayButton_Click(object sender, System.EventArgs e)
    {
        IList<Place.Field> fields = new List<Place.Field>();
        fields.Add(Place.Field.Id);
        fields.Add(Place.Field.LatLng);
        fields.Add(Place.Field.Name);
        fields.Add(Place.Field.Address);

        Intent intent = new Autocomplete.IntentBuilder(AutocompleteActivityMode.Overlay, fields)
            .SetCountry("UK")
            .Build(this);

        StartActivityForResult(intent, 0);

    }`

My minimal repro:

PlacesApi.Initialize(activity, "API_KEY");
var placesClient = PlacesApi.CreateClient(Application.Context);

Also throws NoClassDefFoundErrors - I tried to manually include the missing classes via NuGet but at some point gave up because it was quite a bunch

Guys, I think I screw the nuspec haha, well nothing from the other world. Just forgot to add the dependencies of Google Places.

Please, add them and try again:

<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="28.0.0.1" PrivateAssets="All" />
    <PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="28.0.0.1" PrivateAssets="All" />
    <PackageReference Include="Xamarin.Android.Support.v7.RecyclerView" Version="28.0.0.1" PrivateAssets="All" />
    <PackageReference Include="Xamarin.Android.Support.v4" Version="28.0.0.1" PrivateAssets="All" />
    <PackageReference Include="Xamarin.Android.Volley" Version="1.1.1" PrivateAssets="All" />
    <PackageReference Include="Xamarin.Android.Glide" Version="4.9.0" PrivateAssets="All" />
    <PackageReference Include="Xamarin.GooglePlayServices.Base" Version="71.1601.0-preview3" PrivateAssets="All" />
    <PackageReference Include="Xamarin.GooglePlayServices.Basement" Version="71.1610.0-preview3" PrivateAssets="All" />
    <PackageReference Include="Xamarin.GooglePlayServices.Clearcut" Version="71.1600.0-preview3" PrivateAssets="All" />
    <PackageReference Include="Xamarin.GooglePlayServices.Location" Version="71.1600.0-preview3" PrivateAssets="All" />
    <PackageReference Include="Xamarin.GooglePlayServices.Maps" Version="71.1600.0-preview3" PrivateAssets="All" />
    <PackageReference Include="Xamarin.GooglePlayServices.Tasks" Version="71.1601.0-preview3" PrivateAssets="All" />
    <PackageReference Include="Xamarin.Google.AutoValue.Annotations" Version="1.6.5" PrivateAssets="All" />
    <PackageReference Include="GoogleGson" Version="2.8.5" PrivateAssets="All" />

This will be fixed. Sorry for the inconveniences.

Best!

That is quite a lot of dependencies - are they really all needed (like Glide/RecyclerView/CardView for example)?

That is quite a lot of dependencies - are they really all needed (like Glide/RecyclerView/CardView for example)?

Yes, they are all needed. It's the way Google designed it. You can see the dependencies on Maven:

https://mvnrepository.com/artifact/com.google.android.libraries.places/places/1.1.0

Interesting - thanks! Let's hope they get linked away if not needed :)

I suspect that most of those dependencies are for the AutocompleteActivity and AutoCompleteSupportFragment. If you're not using either of those classes and are just using the API classes directly, they could probably be linked out. But that's probably a separate exercise outside of this task.

I'll try this package ASAP and provide feedback. Thanks @SotoiGhost !!

I managed to install all the dependencies manually,
It worked!!!! like it should

I guess as soon the dependencies are added to the nuspec,
it will be easier to implement.

Thanks to everyone

Closing this one and https://github.com/xamarin/GooglePlayServicesComponents/issues/207

Package was released.

Also version 1.1.0.1 is released with the fix discussed earlier.

Whilst the new Google Places API for Android is working well.
Discovered that there is a slight issue with version 1.1.0.1

The issue was caused by Xamarin.Android.Volley, I had to reinstall the Volley Nuget to get the Places API to work.

On the other hand, cheers to @SotoiGhost @moljac
_Will the Google Places API for Xamarin.iOS be coming out soon?_

Whilst the new Google Places API for Android is working well.
Discovered that there is a slight issue with version 1.1.0.1

The issue was caused by Xamarin.Android.Volley, I had to reinstall the Volley Nuget to get the Places API to work.

On the other hand, cheers to @SotoiGhost @moljac
_Will the Google Places API for Xamarin.iOS be coming out soon?_

I created #217 for that issue. Though the work around is pretty simple (just update the Xamarin.Android.Volley Nuget package to v1.1.1.1 -- Four 1s, not three 1s), it's not very obvious on how to fix it.

@theuchenna The iOS side of G.Places is already out there on NuGet. Google just updated the framework on iOS. They didn't replace it with a new one.

@SharpMobileCode we will work to fix the version soon.

Anyone using PROGUARD for release builds care to share the relevant configuration? I've started with 145 warnings :-( They seem to originate from the inclusion of Volley and some from the Places API itself. I ended up adding a lot to my projects PROGUARD file to get it working which seemed a lot like trial and error?

@SotoiGhost Please when will the iOS update of Google Places API be published, currently my team can't work on any new map based project using Xamarin.iOS. I appreciate you for your swift response on the Android Version of this API, it really saved my team and everyone sends in their regards.

Thanks a bunch,
Am expecting to hear from you.

Hey, I am trying to request places with the new package and some fields might have been mapped wrong? For example for the address component it looks like "address_components" is submitted, the listing here: https://developers.google.com/places/web-service/place-data-fields says we need "address_component". Also Phone number and website doesn't work. Can I overwrite something to fix this myself or do I need to wait for an update?

@SotoiGhost Please when will the iOS update of Google Places API be published, currently my team can't work on any new map-based project using Xamarin.iOS. I appreciate you for your swift response on the Android version of this API, it really saved my team and everyone sends in their regards.

Thanks a bunch,
Am expecting to hear from you.

@SotoiGhost @Redth @moljac

@SotoiGhost Please when will the iOS update of Google Places API be published, currently my team can't work on any new map based project using Xamarin.iOS. I appreciate you for your swift response on the Android Version of this API, it really saved my team and everyone sends in their regards.

Thanks a bunch,
Am expecting to hear from you.

@SharpMobileCode

Was this page helpful?
0 / 5 - 0 ratings