androidkotlingoogle-maps-android-api-2

java.util.concurrent.ExecutionException: java.lang.SecurityException: GoogleCertificatesRslt: not allowed:?


I am developing taksi app when I run app I am getting following exception

Unable to update local snapshot for com.google.android.libraries.consentverifier#com.example.starttaksi, may result in stale flags.
                                                                                                    java.util.concurrent.ExecutionException: java.lang.SecurityException: GoogleCertificatesRslt: not allowed: pkg=com.example.starttaksi, sha256=[f77957bb7143c0754d3c5e22d6c03f0af501037c4a3a8423ada13308aa8eaa05], atk=false, ver=234414038.true (go/gsrlt)
                                                                                                        at m.apa.s(:com.google.android.gms.dynamite_mapsdynamite@234414038@23.44.14 (190400-0):21)
                                                                                                        at m.apa.get(:com.google.android.gms.dynamite_mapsdynamite@234414038@23.44.14 (190400-0):5)
                                                                                                        at m.aqk.g(:com.google.android.gms.dynamite_mapsdynamite@234414038@23.44.14 (190400-0):9)
                                                                                                        at m.yy.c(:com.google.android.gms.dynamite_mapsdynamite@234414038@23.44.14 (190400-0):1)
                                                                                                        at m.zf.run(:com.google.android.gms.dynamite_mapsdynamite@234414038@23.44.14 (190400-0):5)
                                                                                                        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487)
                                                                                                        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:1145)
                                                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                        at java.lang.Thread.run(Thread.java:1012)
                                                                                                    Caused by: java.lang.SecurityException: GoogleCertificatesRslt: not allowed: pkg=com.example.starttaksi, sha256=[f77957bb7143c0754d3c5e22d6c03f0af501037c4a3a8423ada13308aa8eaa05], atk=false, ver=234414038.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.fe.c(:com.google.android.gms.dynamite_mapsdynamite@234414038@23.44.14 (190400-0):11)
                                                                                                        at m.sg.a(:com.google.android.gms.dynamite_mapsdynamite@234414038@23.44.14 (190400-0):39)
                                                                                                        at m.jr.e(:com.google.android.gms.dynamite_mapsdynamite@234414038@23.44.14 (190400-0):11)
                                                                                                        at m.kp.u(:com.google.android.gms.dynamite_mapsdynamite@234414038@23.44.14 (190400-0):10)
                                                                                                        at m.kp.v(:com.google.android.gms.dynamite_mapsdynamite@234414038@23.44.14 (190400-0):22)
                                                                                                        at m.kp.e(:com.google.android.gms.dynamite_mapsdynamite@234414038@23.44.14 (190400-0):16)
                                                                                                        at m.kt.handleMessage(:com.google.android.gms.dynamite_mapsdynamite@234414038@23.44.14 (190400-0):774)

below my MainFragment where I have implemented my google maps logic

@AndroidEntryPoint
class MainFragment : Fragment(R.layout.fragment_main), OnMapReadyCallback {
    private val binding by viewBinding(FragmentMainBinding::bind)
    private lateinit var map: GoogleMap
    private var locationPermissionGranted: Boolean = false
    private var lastKnownLocation: Location? = null
    private lateinit var fusedLocationProviderClient: FusedLocationProviderClient

    companion object {
        val REQUEST_CODE_LOCATION = 32
        private const val DEFAULT_ZOOM = 15
        private const val PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION = 1
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        binding.mapView.onCreate(savedInstanceState)
        binding.mapView.getMapAsync(this)
        fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(requireActivity())

    }

    override fun onMapReady(googleMap: GoogleMap) {
        map = googleMap
        if (ActivityCompat.checkSelfPermission(
                requireContext(),
                Manifest.permission.ACCESS_FINE_LOCATION
            ) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
                requireContext(),
                Manifest.permission.ACCESS_COARSE_LOCATION
            ) != PackageManager.PERMISSION_GRANTED
        ) {
            ActivityCompat.requestPermissions(
                requireActivity(), arrayOf(Manifest.permission.ACCESS_FINE_LOCATION),
                REQUEST_CODE_LOCATION
            )
            return
        }

        locationPermissionGranted = true
        map.isMyLocationEnabled = true

        getDeviceLocation()
    }



    private fun getDeviceLocation() {
        try {
            if (locationPermissionGranted) {
                val locationResult = fusedLocationProviderClient.lastLocation
                locationResult.addOnCompleteListener(requireActivity()) { task ->
                    if (task.isSuccessful) {
                        lastKnownLocation = task.result
                        if (lastKnownLocation != null) {
                            map.moveCamera(
                                CameraUpdateFactory.newLatLngZoom(
                                    LatLng(
                                        lastKnownLocation!!.latitude,
                                        lastKnownLocation!!.longitude
                                    ), DEFAULT_ZOOM.toFloat()
                                )
                            )
                        }
                    }
                }
            }
        } catch (e: SecurityException) {
        }
    }

}

I want to know where I am making mistake what I have to do in order to solve this problem I have tried all StackOverflow suggestion and answers as well and I have tried all possible solutions as well


Solution

  • I fixed problem by adding following methods to my MainFragment.kt class

    override fun onResume() {
            super.onResume()
            binding.mapView.onResume()
        }
    
        override fun onPause() {
            super.onPause()
            binding.mapView.onPause()
        }
    
        override fun onDestroy() {
            super.onDestroy()
            binding.mapView.onDestroy()
        }