Ionic Capacitor Google Maps plugin issue on Android

I’m having issues using Google Maps on Android, it works fine on web and iOS but on Android i keep getting the same error which is:

The google maps plugin i’m using is the official one provided by Capacitor

W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:7
I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version >= 7
W/ziparchive: Unable to open '/data/user_de/0/com.google.android.gms/app_chimera/m/00000014/GoogleCertificates.dm': No such file or directory
W/ziparchive: Unable to open '/data/user_de/0/com.google.android.gms/app_chimera/m/00000014/GoogleCertificates.dm': No such file or directory
I/SnapshotHandler: Unable to retrieve flag snapshot for com.google.android.libraries.consentverifier#com.x.x, using defaults.
W/MobStoreFlagStore: Unable to update local snapshot for com.google.android.libraries.consentverifier#com.x.x, may result in stale flags.
    java.util.concurrent.ExecutionException: java.lang.SecurityException: GoogleCertificatesRslt: not allowed: pkg=com.x.x, sha256=[x], atk=false, ver=230514044.true (go/gsrlt)
        at ajq.s(:com.google.android.gms.dynamite_mapsdynamite@230514044@23.05.14 (190400-0):3)
        at ajq.get(:com.google.android.gms.dynamite_mapsdynamite@230514044@23.05.14 (190400-0):2)
        at ala.g(:com.google.android.gms.dynamite_mapsdynamite@230514044@23.05.14 (190400-0):2)
        at ys.d(:com.google.android.gms.dynamite_mapsdynamite@230514044@23.05.14 (190400-0):1)
        at yu.run(:com.google.android.gms.dynamite_mapsdynamite@230514044@23.05.14 (190400-0):0)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:463)
        at java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:307)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
        at java.lang.Thread.run(Thread.java:1012)
     Caused by: java.lang.SecurityException: GoogleCertificatesRslt: not allowed: pkg=com.x.x, sha256=[x], atk=false, ver=230514044.true (go/gsrlt)

The map does not show at all, it even crashes my app when i attempt to open the map aswell sometimes, but i always get this error.

I have set up the API keys correctly, i think i have placed everything correctly in the manifest aswell.
This is how my Android Manifest looks like currently:

<?xml version="1.0" encoding="utf-8" ?>
<manifest
  xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.x.x"
>

  <!-- Permissions -->
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
  >
      <meta-data
      android:name="com.google.android.geo.API_KEY"
      android:value="xxx"
    />
        <activity
      android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
      android:name="com.x.x.MainActivity"
      android:label="@string/title_activity_main"
      android:theme="@style/AppTheme.NoActionBarLaunch"
      android:launchMode="singleTask"
      android:exported="true"
    >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

      <provider
      android:name="androidx.core.content.FileProvider"
      android:authorities="${applicationId}.fileprovider"
      android:exported="false"
      android:grantUriPermissions="true"
    >
      <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_paths"
      />
      </provider>
    </application>
</manifest>

I’ve bee looking at different websites looking for solutions, like downgrading com.android.tools.build:gradle: to a version that worked for them and so on.
But none of these suggestions have worked, i attempted to ask Google Support to see if they had anything to say but was asked to contact Ionic, and since i’m a free user i have to ask the community, so here we are.

Hope anyone has a solution for this!

1 Like

I was hitting my self against that also last week. Your API Key must have a restriction, either be the platform or de apis it can call.

Hi, I have the same error too. My API key has no restrictions (the one generated by Firebase). As @pnordboj , the map is working fine on iOS and some Android devices. For example, in the Android Studio the map appears correctly but not inspectionating the device through Chrome.

Here you can see how the Google map is initialized and the error I see in the Android Studio logcat:

this.googleMap = await GoogleMap.create({
      id: 'ps-map',
      element: this.mapRef.nativeElement,
      apiKey: environment.googleMapsApiKey,
      config: {
        center: center,
        zoom: 5,
        disableDefaultUI: true,
        styles: this.vesselService.getVesselMapsStyle(),
        tilt: 30,
      },
    });
To native (Capacitor plugin): callbackId: 22000736, pluginId: CapacitorGoogleMaps, methodName: create
callback: 22000736, pluginId: CapacitorGoogleMaps, methodName: create, methodData: {"id":"ps-map","element":{},"apiKey":"xxxxx","config":{"center":{"lat":34.7186666666667,"lng":33.3168333333333},"zoom":5,"disableDefaultUI":true,"styles":[{"elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"elementType":"labels.text.fill","stylers":[{"color":"#1E465F"},{"saturation":36},{"lightness":40},{"visibility":"off"}]},{"elementType":"labels.text.stroke","stylers":[{"color":"#1E465F"},{"lightness":16},{"visibility":"off"}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":20},{"visibility":"off"}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":17},{"visibility":"off"},{"weight":1.2}]},{"featureType":"administrative.country","elementType":"geometry.stroke","stylers":[{"saturation":-100},{"lightness":95},{"visibility":"on"}]},{"featureType":"administrative.country","elementType":"labels.text","stylers":[{"lightness":95},{"visibility":"on"}]},{"featureType":"administrative.country","elementType":"labels.text.stroke","stylers":[{"lightness":95},{"visibility":"simplified"}]},{"featureType":"administrative.locality","elementType":"labels.text","stylers":[{"color":"#000000"},{"lightness":55},{"visibility":"simplified"}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#FFBEAF"},{"lightness":20}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#FFBEAF"},{"lightness":21}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":18},{"visibility":"off"}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#FFBEAF"},{"lightness":17},{"visibility":"off"}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":29},{"visibility":"off"},{"weight":0.2}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":16},{"visibility":"off"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":19},{"visibility":"off"}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#FFFFFF"},{"lightness":15},{"visibility":"on"}]},{"featureType":"water","elementType":"labels.text","stylers":[{"visibility":"on"}]}],"tilt":30,"androidLiteMode":false,"width":345.0909118652344,"height":359.6363830566406,"x":24,"y":985.5227661132812,"devicePixelRatio":2.75}}
getObject calls without a default value will return null in Capacitor 5 instead of an empty object to match iOS behavior
preferredRenderer: null
preferredRenderer: null
Making Creator dynamically
Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:203115000
Selected remote version of com.google.android.gms.maps_dynamite, version >= 203115000
Dynamite loader version >= 2, using loadModule2NoCrashUtils
ClassLoader referenced unknown path: 
Google Play services client version: 12451000
Google Play services package version: 231516040
Google Play services maps renderer version(legacy): 203115000
loadedRenderer: LEGACY
preferredRenderer: null
Google Play services package version: 231516040
Google Play services maps renderer version(legacy): 203115000
Notifying listeners for event onMapReady
No listeners found for event onMapReady
File: http://localhost/ - Line 230 - Msg: undefined
To native (Capacitor plugin): callbackId: 22000737, pluginId: CapacitorGoogleMaps, methodName: addMarker
callback: 22000737, pluginId: CapacitorGoogleMaps, methodName: addMarker, methodData: {"id":"ps-map","marker":{"coordinate":{"lat":34.7186666666667,"lng":33.3168333333333},"title":"Shira E","iconUrl":"assets\/map\/ship100.png","iconSize":{"width":20,"height":34}}}
Successfully registered with Phenotype.
Handling local request: http://localhost/assets/icon/icon_wind.svg
Handling local request: http://localhost/weathericons-regular-webfont.woff2
Local module descriptor class for com.google.android.gms.googlecertificates not found.
Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:7
Selected remote version of com.google.android.gms.googlecertificates, version >= 7
Unable to retrieve flag snapshot for com.google.android.libraries.consentverifier#xxx.portal.test, using defaults.
Unable to update local snapshot for com.google.android.libraries.consentverifier#xxx.portal.test, may result in stale flags.
java.util.concurrent.ExecutionException: java.lang.SecurityException: GoogleCertificatesRslt: not allowed: pkg=xxx.portal.test, sha256=[xxx], atk=false, ver=231516040.true (go/gsrlt)
	at ajg.s(:com.google.android.gms.dynamite_mapsdynamite@231516040@23.15.16 (150700-0):3)
	at ajg.get(:com.google.android.gms.dynamite_mapsdynamite@231516040@23.15.16 (150700-0):2)
	at akq.g(:com.google.android.gms.dynamite_mapsdynamite@231516040@23.15.16 (150700-0):2)
	at yo.c(:com.google.android.gms.dynamite_mapsdynamite@231516040@23.15.16 (150700-0):1)
	at yq.run(:com.google.android.gms.dynamite_mapsdynamite@231516040@23.15.16 (150700-0):0)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.lang.Thread.run(Thread.java:923)
Caused by: java.lang.SecurityException: GoogleCertificatesRslt: not allowed: pkg=xxx.portal.test, sha256=[xxx], atk=false, ver=231516040.true (go/gsrlt)
	at android.os.Parcel.createExceptionOrNull(Parcel.java:2373)
	at android.os.Parcel.createException(Parcel.java:2357)
	at android.os.Parcel.readException(Parcel.java:2340)
	at android.os.Parcel.readException(Parcel.java:2282)
	at fe.c(:com.google.android.gms.dynamite_mapsdynamite@231516040@23.15.16 (150700-0):2)
	at rs.a(:com.google.android.gms.dynamite_mapsdynamite@231516040@23.15.16 (150700-0):4)
	at jk.e(:com.google.android.gms.dynamite_mapsdynamite@231516040@23.15.16 (150700-0):2)
	at ki.t(:com.google.android.gms.dynamite_mapsdynamite@231516040@23.15.16 (150700-0):2)
	at ki.u(:com.google.android.gms.dynamite_mapsdynamite@231516040@23.15.16 (150700-0):3)
	at ki.e(:com.google.android.gms.dynamite_mapsdynamite@231516040@23.15.16 (150700-0):2)
	at km.handleMessage(:com.google.android.gms.dynamite_mapsdynamite@231516040@23.15.16 (150700-0):74)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:223)
	at android.os.HandlerThread.run(HandlerThread.java:67)



As far as I have read on Internet, the issue is that the Google Maps capacitor starts with mode LEGACY and it should be LATEST. Does someone can fix that?

I’ve been searching this for ages.
Tried different kind of things like a variety versions of gradle or google services, nothing seemed to work. The map was rendering fine on the browser but not on android.
After deciding search the github repo for issues if found those info:
Be sure to read the Android section in this section: Google Maps Capacitor Plugin API | Capacitor Documentation. It has some useful info about how the map is rendered in the webview.

On Android, the map is rendered beneath the entire webview, and uses this component to manage its positioning during scrolling events. This means that as the developer, you must ensure that the webview is transparent all the way through the layers to the very bottom. In a typically Ionic application, that means setting transparency on elements such as IonContent and the root HTML tag to ensure that it can be seen. If you can’t see your map on Android, this should be the first thing you check.

Also you can refer this issue to find out how people with similar problem addressed this issue. Capacitor-Google Maps issue on Android · Issue #953 · ionic-team/capacitor-plugins · GitHub

You see this specific error on android studio console and you might believe that there is something wrong with the key or the google maps or anything.

Turns outs in my case that the map is actually rendered behind the scenes and you have to add the

ion-content {
  --background: transparent;
}

In the global css file. Care, that setting directly in the component did not do the trick.

Also while navigating to other pages the map is actually rendered in the background no matter what. I’m calling the
map.destroy()
to cleanup the references.

Hope this info helps

1 Like

You are totally right and this is the only solution that worked for me! it turns out that the map was hidden somehow. Thank you very much.
Also i added the css in the page of the map and it worked for me.