title: Can't get last known location
body: <p>Not gonna lie, I'm very new in kotlin, that why I need analysis of full code.</p>
  <p><strong>On start it asks for permissions (don't need any more it's just test project)
  Pressing on the button supposed to change textView to my location</strong></p>
  <p>This is the code:</p>
  <pre><code>class MainActivity : AppCompatActivity() {
  
  private lateinit var fusedLocationClient: FusedLocationProviderClient
  private lateinit var text: TextView
  
  
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
  
      text = findViewById(R.id.textView)
      val button: Button = findViewById(R.id.button)
      fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
  
      val requestMultiplePermissions = registerForActivityResult(
          ActivityResultContracts.RequestMultiplePermissions()) { permissions -&gt;
          permissions.entries.forEach {
              Log.e(&quot;DEBUG&quot;, &quot;${it.key} = ${it.value}&quot;)
          }
      }
      button.setOnClickListener {
          getLastKnownLocation()
      }
      requestMultiplePermissions.launch(
          arrayOf(
              Manifest.permission.ACCESS_COARSE_LOCATION,
              Manifest.permission.ACCESS_FINE_LOCATION
          )
      )
  }
  
  
  private fun getLastKnownLocation() {
  
      if (ActivityCompat.checkSelfPermission(
              this,
              Manifest.permission.ACCESS_FINE_LOCATION
          ) != PackageManager.PERMISSION_GRANTED &amp;&amp; ActivityCompat.checkSelfPermission(
              this,
              Manifest.permission.ACCESS_COARSE_LOCATION
          ) != PackageManager.PERMISSION_GRANTED
      ) {
          text.text = &quot;do not grants the permission&quot;
          return
      }
  
      fusedLocationClient.lastLocation
          .addOnSuccessListener { location: Location? -&gt;
              if (location != null) {
                  text.text = &quot;My location &quot; + location.latitude.toString() + &quot;, &quot; + location.longitude.toString()
              }
              else{
                  text.text = &quot;location = null&quot;
              }
          }
  } }
  
  //added to Manifest
  &lt;uses-permission android:name=&quot;android.permission.ACCESS_COARSE_LOCATION&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.ACCESS_FINE_LOCATION&quot; /&gt;
  </code></pre>
  <p><strong>But it wrote &quot;location = null&quot;, wats wrong here?</strong></p>
  <p><a href="https://i.stack.imgur.com/FxSf9.png" rel="nofollow noreferrer">Log</a></p>
  <p>it don't ask for permissions with emulator, I use connected device for tests</p>
  <p>Logcat:</p>
  <pre><code>2021-10-27 14:51:55.818 10025-10025/? I/ample.idssende: Late-enabling -Xcheck:jni
  2021-10-27 14:51:55.818 10025-10025/? I/ample.idssende: Late-enabling -Xcheck:jni
  2021-10-27 14:51:55.818 10025-10025/? I/ample.idssende: Late-enabling -Xcheck:jni
  2021-10-27 14:51:56.009 10025-10025/? E/libc: Access denied finding property &quot;persist.vendor.sys.activitylog&quot;
  2021-10-27 14:51:56.004 10025-10025/? W/re-initialized&gt;: type=1400 audit(0.0:35158): avc: denied { read } for name=&quot;u:object_r:mtk_amslog_prop:s0&quot; dev=&quot;tmpfs&quot; ino=7714 scontext=u:r:untrusted_app:s0:c188,c256,c512,c768 tcontext=u:object_r:mtk_amslog_prop:s0 tclass=file permissive=0
  2021-10-27 14:51:56.009 10025-10025/? E/libc: Access denied finding property &quot;persist.vendor.sys.activitylog&quot;
  2021-10-27 14:51:55.924 16571-16610/? I/MicroDetectionState: Should stop hotword detection immediately - false
  2021-10-27 14:51:56.004 10025-10025/? W/re-initialized&gt;: type=1400 audit(0.0:35158): avc: denied { read } for name=&quot;u:object_r:mtk_amslog_prop:s0&quot; dev=&quot;tmpfs&quot; ino=7714 scontext=u:r:untrusted_app:s0:c188,c256,c512,c768 tcontext=u:object_r:mtk_amslog_prop:s0 tclass=file permissive=0
  2021-10-27 14:51:56.009 10025-10025/? E/libc: Access denied finding property &quot;persist.vendor.sys.activitylog&quot;
  2021-10-27 14:51:56.004 10025-10025/? W/re-initialized&gt;: type=1400 audit(0.0:35158): avc: denied { read } for name=&quot;u:object_r:mtk_amslog_prop:s0&quot; dev=&quot;tmpfs&quot; ino=7714 scontext=u:r:untrusted_app:s0:c188,c256,c512,c768 tcontext=u:object_r:mtk_amslog_prop:s0 tclass=file permissive=0
  2021-10-27 14:51:57.321 10025-10025/com.example.idssender W/ample.idssende: Accessing hidden method Landroid/graphics/drawable/Drawable;-&gt;getOpticalInsets()Landroid/graphics/Insets; (light greylist, linking)
  2021-10-27 14:51:57.321 10025-10025/com.example.idssender W/ample.idssende: Accessing hidden field Landroid/graphics/Insets;-&gt;left:I (light greylist, linking)
  2021-10-27 14:51:57.321 10025-10025/com.example.idssender W/ample.idssende: Accessing hidden field Landroid/graphics/Insets;-&gt;right:I (light greylist, linking)
  2021-10-27 14:51:57.321 10025-10025/com.example.idssender W/ample.idssende: Accessing hidden field Landroid/graphics/Insets;-&gt;top:I (light greylist, linking)
  2021-10-27 14:51:57.321 10025-10025/com.example.idssender W/ample.idssende: Accessing hidden field Landroid/graphics/Insets;-&gt;bottom:I (light greylist, linking)
  2021-10-27 14:51:57.452 10025-10025/com.example.idssender W/ample.idssende: Accessing hidden field Landroid/view/WindowInsets;-&gt;CONSUMED:Landroid/view/WindowInsets; (light greylist, reflection)
  2021-10-27 14:51:57.483 10025-10025/com.example.idssender W/ample.idssende: Accessing hidden method Landroid/view/View;-&gt;getAccessibilityDelegate()Landroid/view/View$AccessibilityDelegate; (light greylist, linking)
  2021-10-27 14:51:57.637 10025-10025/com.example.idssender W/ample.idssende: Accessing hidden method Landroid/view/View;-&gt;computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
  2021-10-27 14:51:57.640 10025-10025/com.example.idssender W/ample.idssende: Accessing hidden method Landroid/view/ViewGroup;-&gt;makeOptionalFitsSystemWindows()V (light greylist, reflection)
  2021-10-27 14:51:58.209 10025-10025/com.example.idssender D/OpenGLRenderer: Skia GL Pipeline
  2021-10-27 14:51:58.211 10025-10025/com.example.idssender I/SurfaceFactory: [static] sSurfaceFactory = com.mediatek.view.impl.SurfaceFactoryImpl@7ee86fd
  2021-10-27 14:51:58.237 10025-10025/com.example.idssender D/ViewRootImpl[MainActivity]: hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false
  2021-10-27 14:51:58.248 10025-10025/com.example.idssender V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@22195f9, this = DecorView@b94e93e[MainActivity]
  2021-10-27 14:51:58.254 10025-10025/com.example.idssender E/DEBUG: android.permission.ACCESS_FINE_LOCATION = true
  2021-10-27 14:51:58.254 10025-10025/com.example.idssender E/DEBUG: android.permission.ACCESS_COARSE_LOCATION = true
  2021-10-27 14:51:58.315 10025-10025/com.example.idssender W/ample.idssende: Accessing hidden method Landroid/graphics/Insets;-&gt;of(IIII)Landroid/graphics/Insets; (light greylist, linking)
  2021-10-27 14:51:58.357 10025-10025/com.example.idssender D/Surface: Surface::allocateBuffers(this=0x78180db000)
  2021-10-27 14:51:58.382 10025-10127/com.example.idssender I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
  2021-10-27 14:51:58.382 10025-10127/com.example.idssender I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
  2021-10-27 14:51:58.382 10025-10127/com.example.idssender I/OpenGLRenderer: Initialized EGL, version 1.4
  2021-10-27 14:51:58.383 10025-10127/com.example.idssender D/OpenGLRenderer: Swap behavior 2
  2021-10-27 14:51:58.383 10025-10127/com.example.idssender E/OpenGLRenderer: Device claims wide gamut support, cannot find matching config, error = EGL_SUCCESS
  2021-10-27 14:51:58.398 10025-10127/com.example.idssender D/Surface: Surface::connect(this=0x78180db000,api=1)
  2021-10-27 14:51:58.402 10025-10127/com.example.idssender D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
  2021-10-27 14:51:58.529 10025-10127/com.example.idssender E/ion: ioctl c0044901 failed with code -1: Invalid argument
  </code></pre>