ReferenceError: google is not defined Android Pie

Hello Ionicers!

I’ve been running an implementation of Google Maps Address autocomplete. it has been working just swimmingly, until the new Android API 28/29. When I run the @ionic/angular app on an Android Pie device I get the “ReferenceError: google is not defined” error.

When I run the same app on an Android 8 device it runs perfectly fine.

What do I need to do differently??

declare var google: any;

updateSearch() {
    console.log('updateSearch - ', this.autocomplete.query);
    if (this.autocomplete.query == '') {
      this.autocompleteItems = [];
      return;
    }
    let me = this;
    this.service.getPlacePredictions({
      input: this.autocomplete.query,
      componentRestrictions: {
        country: 'uk'
      }
    }, (predictions, status) => {
      me.autocompleteItems = [];

      me.zone.run(() => {
        if (predictions != null) {
          predictions.forEach((prediction) => {
            me.autocompleteItems.push(prediction.description);
          });
        }
      });
    });
  }

Did you solve this error?

I solved it, after some hours, just putting two things in AndroidManifest.xml

Open

platforms/android/AndroidManifest.xml

In tag Application put

android:usesCleartextTraffic="true"

and inside tag Application put the tag

<uses-library android:name="org.apache.http.legacy" android:required="false" />