0

I am trying to add Google map in my app. I am using google_maps_flutter version: 0.5.21+7. I have used the following code from Google codelabs. Here is the code

import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  GoogleMapController mapController;

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

  void _onMapCreated(GoogleMapController controller) {
    mapController = controller;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Maps Sample App'),
          backgroundColor: Colors.green[700],
        ),
        body: GoogleMap(
          onMapCreated: _onMapCreated,
          initialCameraPosition: CameraPosition(
            target: _center,
            zoom: 11.0,
          ),
        ),
      ),
    );
  }
}

But the code is not working, map is not showing. Here is the bug report I have got by running on android emulator and the app crashes on real device.

/        (23740): HostConnection::get() New Host Connection established 0xcba7f740, tid 23754
I/zzbz    (23740): Making Creator dynamically
W/mple.test_mapp(23740): Unsupported class loader
W/mple.test_mapp(23740): Skipping duplicate class check due to unsupported classloader
D/EGL_emulation(23740): eglMakeCurrent: 0xded8e8a0: ver 3 0 (tinfo 0xded203c0)
I/DynamiteModule(23740): Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:221
I/DynamiteModule(23740): Selected remote version of com.google.android.gms.maps_dynamite, version >= 221
V/DynamiteModule(23740): Dynamite loader version >= 2, using loadModule2NoCrashUtils
W/mple.test_mapp(23740): Unsupported class loader
W/mple.test_mapp(23740): Skipping duplicate class check due to unsupported classloader
I/Google Maps Android API(23740): Google Play services client version: 12451000
I/Google Maps Android API(23740): Google Play services package version: 19275040
W/mple.test_mapp(23740): Accessing hidden field Ljava/nio/Buffer;->address:J (light greylist, reflection)
E/GoogleMapController(23740): Cannot enable MyLocation layer as location permissions are not granted
I/mple.test_mapp(23740): Background concurrent copying GC freed 7812(1108KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 1783KB/3MB, paused 5.572ms total 32.898ms
D/        (23740): HostConnection::get() New Host Connection established 0xc05b5f40, tid 23799
D/EGL_emulation(23740): eglCreateContext: 0xbf4da240: maj 1 min 0 rcv 1
D/EGL_emulation(23740): eglMakeCurrent: 0xe0785600: ver 3 0 (tinfo 0xc807bd60)
D/EGL_emulation(23740): eglMakeCurrent: 0xbf4da240: ver 1 0 (tinfo 0xbf4c6160)
D/EGL_emulation(23740): eglMakeCurrent: 0xe0785600: ver 3 0 (tinfo 0xc807bd60)
D/        (23740): HostConnection::get() New Host Connection established 0xc05d0700, tid 23752
E/Google Maps Android API(23740): Authorization failure.  Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
E/Google Maps Android API(23740): In the Google Developer Console (https://console.developers.google.com)
E/Google Maps Android API(23740): Ensure that the "Google Maps Android API v2" is enabled.
E/Google Maps Android API(23740): Ensure that the following Android Key exists:
E/Google Maps Android API(23740):   Android Application (<cert_fingerprint>;<package_name>): 0E:5D:3B:4B:C1:50:A0:16:C4:FF:FB:C1:2B:C1:AC:D3:15:25:D3:F6;com.example.test_mapp2
D/EGL_emulation(23740): eglMakeCurrent: 0xe0785600: ver 3 0 (tinfo 0xc807bd60)
D/EGL_emulation(23740): eglMakeCurrent: 0xe0785600: ver 3 0 (tinfo 0xc807bd60)
W/DynamiteModule(23740): Local module descriptor class for com.google.android.gms.googlecertificates not found.
I/DynamiteModule(23740): Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:4
I/DynamiteModule(23740): Selected remote version of com.google.android.gms.googlecertificates, version >= 4
W/mple.test_mapp(23740): Unsupported class loader
W/mple.test_mapp(23740): Skipping duplicate class check due to unsupported classloader
Juthi Sarker Aka
  • 2,217
  • 6
  • 16
  • 22

1 Answers1

1

from this error log E/Google Maps Android API(23740): Authorization failure. Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map. you have an API authorization failure.

i'll leave some links below on how to solve this : Maps Android API: Authorization failure SO answer

griffins
  • 7,079
  • 4
  • 29
  • 54