[google_maps_flutter] Avoid AbstractMethod crash (#2113)
Override a default method to work around flutter/flutter#40126. The root
cause of the issue has already been fixed in master and there is a
potential workaround available to apps already, but this is an extra
low-risk change that should prevent the crash for any affected users
while the fix is still rolling out to stable.
diff --git a/packages/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/CHANGELOG.md
index 926a586..56fbf0e 100644
--- a/packages/google_maps_flutter/CHANGELOG.md
+++ b/packages/google_maps_flutter/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.5.21+6
+
+* Override a default method to work around flutter/flutter#40126.
+
## 0.5.21+5
* Update and migrate iOS example project.
diff --git a/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java b/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java
index f2ea28e..1c70909 100644
--- a/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java
+++ b/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java
@@ -468,6 +468,20 @@
registrar.activity().getApplication().unregisterActivityLifecycleCallbacks(this);
}
+ // @Override
+ // The minimum supported version of Flutter doesn't have this method on the PlatformView interface, but the maximum
+ // does. This will override it when available even with the annotation commented out.
+ public void onInputConnectionLocked() {
+ // TODO(mklim): Remove this empty override once https://github.com/flutter/flutter/issues/40126 is fixed in stable.
+ };
+
+ // @Override
+ // The minimum supported version of Flutter doesn't have this method on the PlatformView interface, but the maximum
+ // does. This will override it when available even with the annotation commented out.
+ public void onInputConnectionUnlocked() {
+ // TODO(mklim): Remove this empty override once https://github.com/flutter/flutter/issues/40126 is fixed in stable.
+ };
+
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
if (disposed || activity.hashCode() != registrarActivityHashCode) {
diff --git a/packages/google_maps_flutter/example/android/build.gradle b/packages/google_maps_flutter/example/android/build.gradle
index 6e12e86..e0d7ae2 100644
--- a/packages/google_maps_flutter/example/android/build.gradle
+++ b/packages/google_maps_flutter/example/android/build.gradle
@@ -5,7 +5,7 @@
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.3.2'
+ classpath 'com.android.tools.build:gradle:3.5.0'
}
}
diff --git a/packages/google_maps_flutter/example/android/gradle.properties b/packages/google_maps_flutter/example/android/gradle.properties
index 8bd86f6..7be3d8b 100644
--- a/packages/google_maps_flutter/example/android/gradle.properties
+++ b/packages/google_maps_flutter/example/android/gradle.properties
@@ -1 +1,2 @@
org.gradle.jvmargs=-Xmx1536M
+android.enableR8=true
diff --git a/packages/google_maps_flutter/example/android/gradle/wrapper/gradle-wrapper.properties b/packages/google_maps_flutter/example/android/gradle/wrapper/gradle-wrapper.properties
index 2819f02..9ec7236 100644
--- a/packages/google_maps_flutter/example/android/gradle/wrapper/gradle-wrapper.properties
+++ b/packages/google_maps_flutter/example/android/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-all.zip
diff --git a/packages/google_maps_flutter/example/test_driver/google_maps.dart b/packages/google_maps_flutter/example/test_driver/google_maps.dart
index 8bcf2e3..90d065f 100644
--- a/packages/google_maps_flutter/example/test_driver/google_maps.dart
+++ b/packages/google_maps_flutter/example/test_driver/google_maps.dart
@@ -5,6 +5,7 @@
import 'dart:async';
import 'dart:io';
+import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_driver/driver_extension.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -638,4 +639,40 @@
expect(topLeft, const ScreenCoordinate(x: 0, y: 0));
});
+
+ test('testResizeWidget', () async {
+ final Completer<GoogleMapController> controllerCompleter =
+ Completer<GoogleMapController>();
+ final GoogleMap map = GoogleMap(
+ initialCameraPosition: _kInitialCameraPosition,
+ onMapCreated: (GoogleMapController controller) async {
+ controllerCompleter.complete(controller);
+ },
+ );
+ await pumpWidget(Directionality(
+ textDirection: TextDirection.ltr,
+ child: MaterialApp(
+ home: Scaffold(
+ body: SizedBox(height: 100, width: 100, child: map)))));
+ final GoogleMapController controller = await controllerCompleter.future;
+
+ await pumpWidget(Directionality(
+ textDirection: TextDirection.ltr,
+ child: MaterialApp(
+ home: Scaffold(
+ body: SizedBox(height: 400, width: 400, child: map)))));
+
+ // We suspected a bug in the iOS Google Maps SDK caused the camera is not properly positioned at
+ // initialization. https://github.com/flutter/flutter/issues/24806
+ // This temporary workaround fix is provided while the actual fix in the Google Maps SDK is
+ // still being investigated.
+ // TODO(cyanglaz): Remove this temporary fix once the Maps SDK issue is resolved.
+ // https://github.com/flutter/flutter/issues/27550
+ await Future<dynamic>.delayed(const Duration(seconds: 3));
+
+ // Simple call to make sure that the app hasn't crashed.
+ final LatLngBounds bounds1 = await controller.getVisibleRegion();
+ final LatLngBounds bounds2 = await controller.getVisibleRegion();
+ expect(bounds1, bounds2);
+ });
}
diff --git a/packages/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/pubspec.yaml
index d4ef98c..71d870f 100644
--- a/packages/google_maps_flutter/pubspec.yaml
+++ b/packages/google_maps_flutter/pubspec.yaml
@@ -2,7 +2,7 @@
description: A Flutter plugin for integrating Google Maps in iOS and Android applications.
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter
-version: 0.5.21+5
+version: 0.5.21+6
dependencies:
flutter: