8

I am working on a Flutter project and have to integrate Google Maps in my project. To do the same, I created a new project on Gogle console, added Maps SDK for android and other APIs I will need and took the key and copy pasted in my AndroidManisfest.xml file.

<meta-data 
    android:name="com.google.android.geo.API_KEY"
    android:value="my_key_here"    
></meta-data>

Now when I go to my Map screen, it just shows me the blank page with small boxes and Google's icon on bottom left corner and zoom in and zoom out icon on bottom right corner. In console it gives error of

Unexpected response code 400 for https://clients4.google.com/glm/mmap/api

Here is the code of my map.dart screen

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:location/location.dart';
import 'package:permission_handler/permission_handler.dart';

class ViewMapsScreen extends StatefulWidget {
  @override
  _ViewMapsScreenState createState() => _ViewMapsScreenState();
}

class _ViewMapsScreenState extends State<ViewMapsScreen> {

  Completer<GoogleMapController> _controller = Completer();

  static const LatLng _center = const LatLng(45.521563, -122.677433);

  void _onMapCreated(GoogleMapController controller) {
    _controller.complete(controller);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        height: MediaQuery.of(context).size.height,
        width: MediaQuery.of(context).size.width,
        child: GoogleMap(
          onMapCreated: _onMapCreated,
          initialCameraPosition: CameraPosition(
            target: _center,
            zoom: 11.0
          )
        ),
      ),
    );
  }
}

Please guys help me out, I am stuck at a rather simple thing to implement.

neerav94
  • 429
  • 1
  • 8
  • 15
  • 1
    can you provide a screenshot of the map you are seeing? – jabamataro Apr 23 '20 at 07:51
  • 2
    Thanks! I solved it. It seems to be an issue with the package and running flutter clean and flutter run twice solves the error. Don't know why though? – neerav94 Apr 24 '20 at 09:22
  • 2
    I ran flutter clean and relaunched buy it is still visible. The following line prints many times on the console: E/Volley (14105): [620] ch.a: Unexpected response code 400 for https://clients4.google.com/glm/mmap/api – Hesam Mar 31 '21 at 16:53
  • 2
    did you find the solution? I am getting these so many times, I can't check my other print()!!! – chichi Jul 04 '21 at 02:52
  • 2
    anyone solve it? – flakerimi Nov 13 '21 at 15:10

1 Answers1

3

To all having this question,

Go to https://console.cloud.google.com/apis/credentials

Add Package name & SHA1 Fingerprint

enter image description here

flakerimi
  • 2,580
  • 3
  • 29
  • 49