Today I wanted to compile my App and I find that the version of GoogleMaps expired, at least I understand that. I leave the error that I get:
Compiler message:
lib/lista_negocio_detalle/map.dart:44:15: Error: Method not found: 'MarkerOptions'.
MarkerOptions(
^^^^^^^^^^^^^
lib/lista_negocio_detalle/map.dart:54:9: Error: No named parameter with the name 'trackCameraPosition'.
trackCameraPosition: true,
^^^^^^^^^^^^^^^^^^^
file:///C:/Users/Emi/Downloads/flutter/.pub-cache/git/plugins-9017d6e7f867af278edd7e8e584d52524f37443f/packages/google_maps_flutter/lib/src/google_map.dart:18:9: Context: Found this candidate, but the arguments don't match.
const GoogleMap({
^
Compiler failed on C:\Users\Emi\AndroidStudioProjects\vivi_carhue\lib\inicio_splash\main.dart
*********************************************************
WARNING: This version of google_maps_flutter will break your Android build if it or its dependencies aren't compatible with AndroidX.
See https ****** for more information on the problem and how to fix it.
This warning prints for all Android build failures. The real root cause of the error may be unrelated.
*********************************************************
Finished with error: Gradle task assembleDebug failed with exit code 1
This is my map class code:
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
class map extends StatefulWidget {
String x, y;
map(this.x, this.y);
Marker _selectedMarker;
@override
_map createState() => _map(x, y);
}
class _map extends State<map> {
String x, y;
_map(this.x, this.y);
Widget build(BuildContext context) {
// TODO: implement build
GoogleMapController myController;
final Maps = Container(
height: 100.0, //altura
width: 40.0, //anchura
margin: EdgeInsets.only(
top: 30.0,
left: 30.0,
right: 30.0,
bottom: 60.0,
),
decoration: BoxDecoration(
color: Color(0xFFFFFFFF),
borderRadius: BorderRadius.circular(2.0),
boxShadow: [new BoxShadow( //SOMBRA
color: Color(0xffA4A4A4),
offset: Offset(1.0, 1.0),
blurRadius: 3.0,
),]
),
child: GoogleMap(
onMapCreated: (controller) {
setState(() {
myController = controller;
});
myController.addMarker(
MarkerOptions(
draggable: false,
position: LatLng(double.parse(x), double.parse(y))
)
);
},
myLocationEnabled: true,
scrollGesturesEnabled: false,
mapType: MapType.normal,
compassEnabled: false,
trackCameraPosition: true,
/*MarkerOptions: MarkerOptions(
position: LatLng(double.parse(source)x, double.parse(source)y) ;
),*/
initialCameraPosition: CameraPosition(
tilt: (25.0),
zoom: 15.9,
target: LatLng(double.parse(x), double.parse(y)),
),
),
);
final texto = Container(
child: Text(
"Ubicación",
style: TextStyle(
fontSize: 16.0,
color: Colors.black
),
),
width: 50.0,
height: 10.0,
);
return Maps;
}
}
and this is my pubspec.yaml
name: vivi_carhue
description: A new Flutter application.
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# Read more about versioning at semver.org.
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
wave: ^0.0.8
font_awesome_flutter: ^8.2.0
url_launcher: '>=0.1.2'
http: ^0.12.0
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
google_maps_flutter:
git:
url: git://github.com/flutter/plugins
path: packages/google_maps_flutter
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
fonts:
- family: Monika
fonts:
- asset: fonts/Monika.TTF
assets:
- fotos/fondo.jpg
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
compile error:
* Error running Gradle:
ProcessException: Process "C:\Users\Emi\AndroidStudioProjects\vivi_carhue\android\gradlew.bat" exited abnormally:
FAILURE: Build failed with an exception.
* What went wrong:
Multiple projects in this build have project directory 'C:\Users\Emi\AndroidStudioProjects\vivi_carhue\android': [:vivi_carhue, :]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
Command: C:\Users\Emi\AndroidStudioProjects\vivi_carhue\android\gradlew.bat app:properties
Finished with error: Please review your Gradle project setup in the android/ folder.
The package
GoogleMaps
is constantly being updated, the Flutter team still doesn't recommend using it in production, and be very careful as they are breaking things all the time.The error you mention is because in the latest version neither is used
MarkerOptions
anymoretrackCameraPosition
.If you use the callBack the
onCameraMove
, assume ittrackCameraPosition
is true.It also changed the way to add Markers, you can see it in this example: https://github.com/flutter/plugins/blob/master/packages/google_maps_flutter/example/lib/place_marker.dart
They no longer use
MarkerOptions