diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/GoogleMapControllerTest.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/GoogleMapControllerTest.java index 52576962ba8d..a45da5035c69 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/GoogleMapControllerTest.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/GoogleMapControllerTest.java @@ -22,6 +22,7 @@ import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodChannel; import java.util.HashMap; +import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -41,19 +42,32 @@ public class GoogleMapControllerTest { private ComponentActivity activity; private GoogleMapController googleMapController; + AutoCloseable mockCloseable; @Mock BinaryMessenger mockMessenger; @Mock GoogleMap mockGoogleMap; @Before public void before() { - MockitoAnnotations.initMocks(this); + mockCloseable = MockitoAnnotations.openMocks(this); context = ApplicationProvider.getApplicationContext(); - activity = Robolectric.setupActivity(ComponentActivity.class); + setUpActivityLegacy(); googleMapController = new GoogleMapController(0, context, mockMessenger, activity::getLifecycle, null); googleMapController.init(); } + // TODO(stuartmorgan): Update this to a non-deprecated test API. + // See https://github.com/flutter/flutter/issues/122102 + @SuppressWarnings("deprecation") + private void setUpActivityLegacy() { + activity = Robolectric.setupActivity(ComponentActivity.class); + } + + @After + public void tearDown() throws Exception { + mockCloseable.close(); + } + @Test public void DisposeReleaseTheMap() throws InterruptedException { googleMapController.onMapReady(mockGoogleMap); diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/MarkersControllerTest.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/MarkersControllerTest.java index 3ca78e7674d7..08b157435672 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/MarkersControllerTest.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/MarkersControllerTest.java @@ -42,14 +42,14 @@ public void controller_OnMarkerDragStart() { when(googleMap.addMarker(any(MarkerOptions.class))).thenReturn(marker); final LatLng latLng = new LatLng(1.1, 2.2); - final Map markerOptions = new HashMap(); + final Map markerOptions = new HashMap<>(); markerOptions.put("markerId", googleMarkerId); final List markers = Arrays.asList(markerOptions); controller.addMarkers(markers); controller.onMarkerDragStart(googleMarkerId, latLng); - final List points = new ArrayList(); + final List points = new ArrayList<>(); points.add(latLng.latitude); points.add(latLng.longitude); @@ -75,14 +75,14 @@ public void controller_OnMarkerDragEnd() { when(googleMap.addMarker(any(MarkerOptions.class))).thenReturn(marker); final LatLng latLng = new LatLng(1.1, 2.2); - final Map markerOptions = new HashMap(); + final Map markerOptions = new HashMap<>(); markerOptions.put("markerId", googleMarkerId); final List markers = Arrays.asList(markerOptions); controller.addMarkers(markers); controller.onMarkerDragEnd(googleMarkerId, latLng); - final List points = new ArrayList(); + final List points = new ArrayList<>(); points.add(latLng.latitude); points.add(latLng.longitude); @@ -108,14 +108,14 @@ public void controller_OnMarkerDrag() { when(googleMap.addMarker(any(MarkerOptions.class))).thenReturn(marker); final LatLng latLng = new LatLng(1.1, 2.2); - final Map markerOptions = new HashMap(); + final Map markerOptions = new HashMap<>(); markerOptions.put("markerId", googleMarkerId); final List markers = Arrays.asList(markerOptions); controller.addMarkers(markers); controller.onMarkerDrag(googleMarkerId, latLng); - final List points = new ArrayList(); + final List points = new ArrayList<>(); points.add(latLng.latitude); points.add(latLng.longitude); diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/android/build.gradle b/packages/google_maps_flutter/google_maps_flutter_android/example/android/build.gradle index 538fd31e3eb1..aafa58af8bac 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/android/build.gradle +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/android/build.gradle @@ -35,9 +35,17 @@ task clean(type: Delete) { gradle.projectsEvaluated { project(":google_maps_flutter_android") { tasks.withType(JavaCompile) { - // TODO(stuartmorgan): Enable this. See - // https://github.com/flutter/flutter/issues/91868 - //options.compilerArgs << "-Xlint:all" << "-Werror" + // Ignore classfile warnings due to https://bugs.openjdk.org/browse/JDK-8190452 + // TODO(stuartmorgan): Remove that ignore once the build uses Java 11+. + options.compilerArgs << "-Xlint:all" << "-Werror" << "-Xlint:-classfile" + // Workaround for a warning when building that the above turns into + // an error, coming from jetified-play-services-maps-18.1.0: + // warning: Cannot find annotation method 'value()' in type + // 'GuardedBy': class file for + // javax.annotation.concurrent.GuardedBy not found + dependencies { + implementation "com.google.code.findbugs:jsr305:3.0.2" + } } } } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/android/gradle.properties b/packages/google_maps_flutter/google_maps_flutter_android/example/android/gradle.properties index c6c9db00b996..598d13fee446 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/android/gradle.properties +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/android/gradle.properties @@ -1,5 +1,3 @@ org.gradle.jvmargs=-Xmx4G -android.enableR8=true android.useAndroidX=true android.enableJetifier=true -