-1

When I navigate to the activity where the map should load on screen, it doesn't and just shows the background of the app, even though it reaches the OnMapReady() method. I have tried it one time before in another project and it worked, but in this one it doesn't. In logcat there are no errors but there is some yellow text. Any help would be greatly appreciated, thank you. screenshot

This is shown in logcat (the same thing is shown in the other project where it still loads the map):

Unable to update local snapshot for com.google.android.libraries.consentverifier#si.me.fritheway3, may result in stale flags.
          
                                                                        java.util.concurrent.ExecutionException: java.lang.SecurityException: GoogleCertificatesRslt: not allowed: pkg=si.me.fritheway3, sha256=[9aaef9cd6f47906ba7c525c279337822d80e5bb94819916c4c76becc7f2e2e26], atk=false, ver=233013044.true (go/gsrlt)
                                                                                                        at m.ank.s(:com.google.android.gms.dynamite_mapsdynamite@233013044@23.30.13 (190400-0):21)
                                                                                                        at m.ank.get(:com.google.android.gms.dynamite_mapsdynamite@233013044@23.30.13 (190400-0):5)
                                                                                                        at m.app.a(:com.google.android.gms.dynamite_mapsdynamite@233013044@23.30.13 (190400-0):2)
                                                                                                        at m.aou.h(:com.google.android.gms.dynamite_mapsdynamite@233013044@23.30.13 (190400-0):7)
                                                                                                        at m.zm.c(:com.google.android.gms.dynamite_mapsdynamite@233013044@23.30.13 (190400-0):1)
                                                                                                        at m.zo.run(:com.google.android.gms.dynamite_mapsdynamite@233013044@23.30.13 (190400-0):5)
                                                                                                        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=si.me.fritheway3, sha256=[9aaef9cd6f47906ba7c525c279337822d80e5bb94819916c4c76becc7f2e2e26], atk=false, ver=233013044.true (go/gsrlt)
                                                                                                        at android.os.Parcel.createExceptionOrNull(Parcel.java:3023)
                                                                                                        at android.os.Parcel.createException(Parcel.java:3007)
                                                                                                        at android.os.Parcel.readException(Parcel.java:2990)
                                                                                                        at android.os.Parcel.readException(Parcel.java:2932)
                                                                                                        at m.fh.c(:com.google.android.gms.dynamite_mapsdynamite@233013044@23.30.13 (190400-0):11)
                                                                                                        at m.sb.a(:com.google.android.gms.dynamite_mapsdynamite@233013044@23.30.13 (190400-0):39)
                                                                                                        at m.jo.e(:com.google.android.gms.dynamite_mapsdynamite@233013044@23.30.13 (190400-0):11)
                                                                                                        at m.km.t(:com.google.android.gms.dynamite_mapsdynamite@233013044@23.30.13 (190400-0):10)
                                                                                                        at m.km.u(:com.google.android.gms.dynamite_mapsdynamite@233013044@23.30.13 (190400-0):22)
                                                                                                        at m.km.e(:com.google.android.gms.dynamite_mapsdynamite@233013044@23.30.13 (190400-0):16)
                                                                                                        at m.kq.handleMessage(:com.google.android.gms.dynamite_mapsdynamite@233013044@23.30.13 (190400-0):774)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:226)
                                                                                                        at android.os.Looper.loop(Looper.java:313)
                                                                                                        at android.os.HandlerThread.run(HandlerThread.java:67)

This same thing is also shown in the project where the maps loads just fine. Here is my Activity file:

class NavigationActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMapClickListener {


    private val permCodes = 0
    private val TAG = "Navigation"

    private lateinit var binding:ActivityNavigationBinding
    private lateinit var mMap: GoogleMap



    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityNavigationBinding.inflate(layoutInflater)
        setContentView(binding.root)

        (supportFragmentManager
            .findFragmentById(si.jurijdolenc.fritheway3.R.id.map) as SupportMapFragment)
            .getMapAsync(this)

        //this should be everything in onCreate

    }

    override fun onMapReady(p0: GoogleMap) {
        mMap = p0
        Log.d(TAG,"Map Ready")
        //mMap.isMyLocationEnabled = false

    }

    override fun onMapClick(p0: LatLng) {
        Log.d(TAG, "CLicked me!")
    }
}

I also think my dependencies are set up right, however I am not so sure about that either now, so here is what I have.

My module build.gradle:

plugins {
    ...
    id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
}

android {

    compileSdk 33
    ...
    defaultConfig {
        ...
        minSdk 24
        targetSdk 33
        ...

        Properties properties = new Properties()

        properties.load(project.rootProject.file('local.properties').newDataInputStream())
        manifestPlaceholders = [MAPS_API_KEY: "${properties.getProperty('MAPS_API_KEY')}"]
    }

    ...
    buildFeatures {
        viewBinding true
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.8.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

    implementation 'com.indooratlas.android:indooratlas-android-sdk:3.4.12@aar'
    implementation 'com.squareup.picasso:picasso:2.8'

    implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'

    implementation 'com.google.code.gson:gson:2.10.1'

    implementation 'com.google.android.gms:play-services-location:21.0.1'
    implementation 'com.google.android.gms:play-services-maps:18.1.0'
}

My app build.gradle:

plugins {
   ...
    id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' version '2.0.1' apply false
}

My Android Manifest:


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

    <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.BLUETOOTH_SCAN" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.BLUETOOTH" />

    <application
        .
        .
        .>
        
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="${MAPS_API_KEY}" />

        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

In local.properties I have my MAPS_API_KEY and it is correct. I honestly don't know in which direction to go. I have read a couple questions here such as:

... but I still couldn't solve it. So if anyone could help me, it would be greatly appreciated. <3 If I missed anything, please let me know.

  • Wild guess: the default location for a map is 0.0,0.0 which puts the map in the South Atlantic Ocean. The default zoom may be device dependent - on my emulator it is 17.74 which then shows only blue (ocean). Note: I get the same certificate issues and evidently has nothing to do with your issue. It's a good practice to always set the default location to something applicable to your app (user location or some known location). – Computable Aug 13 '23 at 23:07

1 Answers1

0

I have recently floated Google Maps on my app and will share you the code that was effective for me.

Xml:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/map_fragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".fragment.MapFragment">

    <com.google.android.gms.maps.MapView
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="@string/map" />

    ...


</androidx.constraintlayout.widget.ConstraintLayout>

Fragment:

class MapFragment : Fragment(), OnMapReadyCallback {

    private lateinit var mapView: MapView
    private lateinit var googleMap: GoogleMap
    private lateinit var viewModel: MapViewModel
    private var currentMarker: Marker? = null

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val rootView = inflater.inflate(R.layout.fragment_map, container, false)

        mapView = rootView.findViewById(R.id.mapView)
        mapView.onCreate(savedInstanceState)
        mapView.getMapAsync(this)
    
        viewModel = MapViewModel(LocationRepository(fusedLocationClient))

        return rootView
    }

    override fun onMapReady(googleMap: GoogleMap) {
        this.googleMap = googleMap
    }
    
    override fun onStart() {
        super.onStart()
        mapView.onStart()
    }

    override fun onStop() {
        super.onStop()
        mapView.onStop()
    }

    override fun onResume() {
        super.onResume()
        mapView.onResume()
    }

    override fun onPause() {
        super.onPause()
        mapView.onPause()
    }

    override fun onLowMemory() {
        super.onLowMemory()
        mapView.onLowMemory()
    }

    override fun onDestroy() {
        mapView.onDestroy()
        super.onDestroy()
    }

Manifest:

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

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.YourTheme"
        tools:targetApi="31">

        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="YOUR_API_KEY" />
Sarah
  • 175
  • 4