skip to Main Content

1-. Use case.

I’m using the google_maps_flutter package, in a Flutter and Dart project. Version is google_maps_flutter: ^2.4.0

When I call to the GoogleMaps widget in Flutter:

enter image description here

the following SecurityException is thrown:

enter image description here

2-. Implemented API key

I followed the guide described in the google_maps_flutter package (https://pub.dev/packages/google_maps_flutter), the guide for installing Google Maps SDK in Flutter (https://developers.google.com/maps/flutter-package/config?authuser=0#step_1_install_the_required_software), and the ‘Maps SDK for Android Quickstart’ documentation (https://developers.google.com/maps/documentation/android-sdk/start) ->

i) GMP API key generated
The api key related to Maps API is the fourth one ->

enter image description here

… with the following api key ->

enter image description here

… and restrictions ->

enter image description here

enter image description here

ii) the android manifest.xml is ->

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
   <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
   <application
       android:label="appname"
       android:name="${applicationName}"
       android:icon="@mipmap/ic_launcher">
       <activity
           android:name=".MainActivity"
           android:exported="true"
           android:launchMode="singleTop"
           android:theme="@style/LaunchTheme"
           android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
           android:hardwareAccelerated="true"
           android:windowSoftInputMode="adjustResize">


           <!-- Specifies an Android theme to apply to this Activity as soon as
                the Android process has started. This theme is visible to the user
                while the Flutter UI initializes. After that, this theme continues
                to determine the Window background behind the Flutter UI. -->
           <meta-data
             android:name="io.flutter.embedding.android.NormalTheme"
             android:resource="@style/NormalTheme"
             />


           <meta-data
               android:name="io.flutter.embedding.android.SplashScreenDrawable"
               android:resource="@drawable/launch_background"
               />


           <intent-filter>
               <action android:name="android.intent.action.MAIN"/>
               <category android:name="android.intent.category.LAUNCHER"/>
           </intent-filter>
       </activity>
       <!-- Don't delete the meta-data below.
            This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
       <meta-data
           android:name="flutterEmbedding"
           android:value="2" />


       <meta-data android:name="com.google.android.geo.API_KEY"
           android:value="${MAPS_API_KEY}"/>


   </application>
</manifest>

iii) the settings.graddle is ->

enter image description here

iv) the secrets.properties is ->

enter image description here

V) the local.defaults.properties is ->

enter image description here

vi) the android/build.gradle is ->

enter image description here

vii) the app/build.gradle is ->

plugins {
   id "com.android.application"
   id "kotlin-android"
   id "dev.flutter.flutter-gradle-plugin"
   id "com.google.gms.google-services"
   id "com.google.android.libraries.mapsplatform.secrets-gradle-plugin"
}


def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
   localPropertiesFile.withReader('UTF-8') { reader ->
       localProperties.load(reader)
   }
}


def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
   flutterVersionCode = '1'
}


def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
   flutterVersionName = '1.0'
}


def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
   keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}


android {
   namespace "com.byroomnumber.brnapp"
   compileSdk flutter.compileSdkVersion
   ndkVersion flutter.ndkVersion


   compileOptions {
       sourceCompatibility JavaVersion.VERSION_1_8
       targetCompatibility JavaVersion.VERSION_1_8
   }


   kotlinOptions {
       jvmTarget = '1.8'
   }


   sourceSets {
       main.java.srcDirs += 'src/main/kotlin'
   }


   defaultConfig {
       // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
       applicationId "com.example.appName"
       // You can update the following values to match your application needs.
       // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
       minSdkVersion 21
       targetSdkVersion 34
       multiDexEnabled true
       versionCode flutterVersionCode.toInteger()
       versionName flutterVersionName
   }


   signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }
   buildTypes {
       release {
           signingConfig signingConfigs.release
       }
   }
   buildFeatures{
       buildConfig true
   }


}


flutter {
   source '../..'
}


dependencies {
   implementation platform("com.google.firebase:firebase-bom:30.7.1")
   implementation("androidx.multidex:multidex:2.0.1")
   implementation "com.google.firebase:firebase-analytics"
   implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.21"
   implementation 'com.google.android.gms:play-services-maps:18.2.0'
}


secrets {
   // Optionally specify a different file name containing your secrets.
   // The plugin defaults to "local.properties"
   propertiesFileName = "secrets.properties"


   // A properties file containing default secret values. This file can be
   // checked in version control.
   defaultPropertiesFileName = "local.defaults.properties"


   // Configure which keys should be ignored by the plugin by providing regular expressions.
   // "sdk.dir" is ignored by default.
   ignoreList.add("keyToIgnore") // Ignore the key "keyToIgnore"
   ignoreList.add("sdk.*")       // Ignore all keys matching the regexp "sdk.*"
}
  1. Expected results

The map is correctly rendered in a device connected via usb, although the exception is thrown.
If an apk is generated and installed on the device, the map is not rendered, and the exception is thrown.

  1. Do you try using other devices?

Yes. I verified this process in a SMA426B and and a MiT11

3

Answers


  1. Chosen as BEST ANSWER

    In order to give a more detailed information to the problem, I enclose the previous and forward information given in terminal, in addition to the error itself:

    D/ConnectivityManager( 2402): StackLog: [android.net.ConnectivityManager.sendRequestForNetwork(ConnectivityManager.java:4322)] [android.net.ConnectivityManager.sendRequestForNetwork(ConnectivityManager.java:4364)] [android.net.ConnectivityManager.registerNetworkCallback(ConnectivityManager.java:4746)] [android.net.ConnectivityManager.registerNetworkCallback(ConnectivityManager.java:4716)] [m.fbc.h(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:41)] [m.fbc.<init>(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:140)] [com.google.maps.api.android.lib6.impl.hz.<init>(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:7)] [com.google.android.gms.maps.internal.CreatorImpl.c(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:1157)] [com.google.android.gms.maps.internal.CreatorImpl.logInitialization(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:16)] [com.google.android.gms.maps.internal.i.bp(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:75)] [m.bcb.onTransact(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:21)]
    D/MapsInitializer( 2402): loadedRenderer: LATEST
    D/zzcc    ( 2402): preferredRenderer: null
    I/Google Android Maps SDK( 2402): Google Play services package version: 240315038
    I/Google Android Maps SDK( 2402): Google Play services maps renderer version(maps_core): 234210304
    D/CompatibilityChangeReporter( 2402): Compat change id reported: 171228096; UID 10486; state: ENABLED
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    D/ConnectivityManager( 2402): StackLog: [android.net.ConnectivityManager.sendRequestForNetwork(ConnectivityManager.java:4322)] [android.net.ConnectivityManager.registerDefaultNetworkCallbackForUid(ConnectivityManager.java:4886)] [android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:4853)] [android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:4827)] [m.azp.a(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:53)] [m.ayw.e(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:34)] [m.ayt.a(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:1)] [m.amc.<init>(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:133)] [com.google.maps.api.android.lib6.phoenix.u.<init>(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:1)] [m.ale.a(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:3)] [m.azi.a(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:131)] [m.alg.c(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:12)] [m.esa.a(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:9)] [m.iph.a(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:14)] [m.esb.run(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:44)] [m.caw.run(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:6)] [m.cci.run(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:8)] [java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)] [java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)] [m.cbt.run(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:42)] [java.lang.Thread.run(Thread.java:1012)]
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    I/PlatformViewsController( 2402): Hosting view in view hierarchy for platform view: 0
    I/PlatformViewsController( 2402): PlatformView is using SurfaceProducer backend
    E/GoogleApiManager( 2402): Failed to get service from broker. 
    E/GoogleApiManager( 2402): java.lang.SecurityException: Unknown calling package name 'com.google.android.gms'.
    E/GoogleApiManager( 2402):  at android.os.Parcel.createExceptionOrNull(Parcel.java:2438)
    E/GoogleApiManager( 2402):  at android.os.Parcel.createException(Parcel.java:2422)
    E/GoogleApiManager( 2402):  at android.os.Parcel.readException(Parcel.java:2405)
    E/GoogleApiManager( 2402):  at android.os.Parcel.readException(Parcel.java:2347)
    E/GoogleApiManager( 2402):  at m.cqy.q(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:180)
    E/GoogleApiManager( 2402):  at m.cpk.run(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:54)
    E/GoogleApiManager( 2402):  at android.os.Handler.handleCallback(Handler.java:938)
    E/GoogleApiManager( 2402):  at android.os.Handler.dispatchMessage(Handler.java:99)
    E/GoogleApiManager( 2402):  at android.os.Looper.loopOnce(Looper.java:226)
    E/GoogleApiManager( 2402):  at android.os.Looper.loop(Looper.java:313)
    E/GoogleApiManager( 2402):  at android.os.HandlerThread.run(HandlerThread.java:67)
    D/OpenGLRenderer( 2402): eglCreateWindowSurface
    I/BufferQueueProducer( 2402): [ImageReader-720x1510f22m4-2402-0](id:96200000004,api:1,p:2402,c:2402) queueBuffer: queued for the first time.
    E/FrameEvents( 2402): updateAcquireFence: Did not find frame.
    W/MobStoreFlagStore( 2402): Unable to update local snapshot for com.google.android.gms.maps#com.google.android.gms, may result in stale flags.
    W/MobStoreFlagStore( 2402): java.util.concurrent.ExecutionException: m.few: 17: 17: API: Phenotype.API is not available on this device. Connection failed with: cmc{statusCode=DEVELOPER_ERROR, resolution=null, message=null}
    W/MobStoreFlagStore( 2402):     at m.gua.s(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:21)
    W/MobStoreFlagStore( 2402):     at m.gua.get(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:5)
    W/MobStoreFlagStore( 2402):     at m.gwy.a(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:2)
    W/MobStoreFlagStore( 2402):     at m.gvt.h(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:10)
    W/MobStoreFlagStore( 2402):     at m.fgk.c(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:1)
    W/MobStoreFlagStore( 2402):     at m.fgr.run(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:5)
    W/MobStoreFlagStore( 2402):     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487)
    W/MobStoreFlagStore( 2402):     at java.util.concurrent.FutureTask.run(FutureTask.java:264)
    W/MobStoreFlagStore( 2402):     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:307)
    W/MobStoreFlagStore( 2402):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    W/MobStoreFlagStore( 2402):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
    W/MobStoreFlagStore( 2402):     at java.lang.Thread.run(Thread.java:1012)
    W/MobStoreFlagStore( 2402): Caused by: m.few: 17: 17: API: Phenotype.API is not available on this device. Connection failed with: cmc{statusCode=DEVELOPER_ERROR, resolution=null, message=null}
    W/MobStoreFlagStore( 2402):     at m.fey.a(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:13)
    W/MobStoreFlagStore( 2402):     at m.gtx.e(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:3)
    W/MobStoreFlagStore( 2402):     at m.gtz.run(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:139)
    W/MobStoreFlagStore( 2402):     at m.guz.execute(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:1)
    W/MobStoreFlagStore( 2402):     at m.gua.q(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:1)
    W/MobStoreFlagStore( 2402):     at m.gua.k(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:96)
    W/MobStoreFlagStore( 2402):     at m.gua.n(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:19)
    W/MobStoreFlagStore( 2402):     at m.fbx.a(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:35)
    W/MobStoreFlagStore( 2402):     at m.cyi.run(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:12)
    W/MobStoreFlagStore( 2402):     at m.guz.execute(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:1)
    W/MobStoreFlagStore( 2402):     at m.cyj.a(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:12)
    W/MobStoreFlagStore( 2402):     at m.cyr.b(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:36)
    W/MobStoreFlagStore( 2402):     at m.cyv.g(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:20)
    W/MobStoreFlagStore( 2402):     at m.cyf.run(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:83)
    W/MobStoreFlagStore( 2402):     at m.guz.execute(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:1)
    W/MobStoreFlagStore( 2402):     at m.cyg.a(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:8)
    W/MobStoreFlagStore( 2402):     at m.cyr.b(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:36)
    W/MobStoreFlagStore( 2402):     at m.cys.c(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:25)
    W/MobStoreFlagStore( 2402):     at m.coj.c(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:7)
    W/MobStoreFlagStore( 2402):     at m.cpi.s(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:48)
    W/MobStoreFlagStore( 2402):     at m.cpi.f(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:10)
    W/MobStoreFlagStore( 2402):     at m.cpi.j(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:177)
    I/GoogleMapController( 2402): Installing custom TextureView driven invalidator.
    W/MobStoreFlagStore( 2402):     at m.cpi.i(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:2)
    W/MobStoreFlagStore( 2402):     at m.cpk.run(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:82)
    W/MobStoreFlagStore( 2402):     at android.os.Handler.handleCallback(Handler.java:938)
    W/MobStoreFlagStore( 2402):     at android.os.Handler.dispatchMessage(Handler.java:99)
    W/MobStoreFlagStore( 2402):     at android.os.Looper.loopOnce(Looper.java:226)
    W/MobStoreFlagStore( 2402):     at android.os.Looper.loop(Looper.java:313)
    W/MobStoreFlagStore( 2402):     at android.os.HandlerThread.run(HandlerThread.java:67)
    W/MobStoreFlagStore( 2402): Caused by: m.cno: 17: API: Phenotype.API is not available on this device. Connection failed with: cmc{statusCode=DEVELOPER_ERROR, resolution=null, message=null}
    W/MobStoreFlagStore( 2402):     at m.cqp.a(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:13)
    W/MobStoreFlagStore( 2402):     at m.coj.c(:com.google.android.gms.policy_maps_core_dynamite@[email protected]:3)
    W/MobStoreFlagStore( 2402):     ... 10 more
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    E/GoogleMapController( 2402): Cannot enable MyLocation layer as location permissions are not granted
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    W/ProxyAndroidLoggerBackend( 2402): Too many Flogger logs received before configuration. Dropping old logs.
    I/omnumber.brnap( 2402): Background concurrent copying GC freed 10187(905KB) AllocSpace objects, 34(1632KB) LOS objects, 49% free, 11MB/22MB, paused 2.768ms,345us total 145.905ms
    I/BufferQueueProducer( 2402): [SurfaceTexture-0-2402-0](id:96200000005,api:1,p:2402,c:2402) queueBuffer: queued for the first time.
    E/FrameEvents( 2402): updateAcquireFence: Did not find frame.
    E/FrameEvents( 2402): updateAcquireFence: Did not find frame.
    

    I suppose it is not a problem of Google Play Services, since it is correctly read...


  2. You also need to add INTERNET permission, add this line to androidManifes.xml

    <uses-permission android:name="android.permission.INTERNET" />
    
    Login or Signup to reply.
  3. In you project level gradle change version of google play services to 4.3.15 in Plugins section.

    id "com.google.gms.google-services" version "4.3.15" apply false
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search