title: App crashing while implementing current location in android studio
body: <blockquote>
    <p>home.java</p>
  </blockquote>
  
  <pre><code>package com.example.nitctraveltogether;
  
  import androidx.annotation.NonNull;
  import androidx.annotation.Nullable;
  import androidx.fragment.app.FragmentActivity;
  
  import android.location.Location;
  import android.os.Bundle;
  
  import com.google.android.gms.common.ConnectionResult;
  import com.google.android.gms.common.api.GoogleApiClient;
  import com.google.android.gms.location.LocationRequest;
  import com.google.android.gms.location.LocationServices;
  import com.google.android.gms.maps.CameraUpdateFactory;
  import com.google.android.gms.maps.GoogleMap;
  import com.google.android.gms.maps.OnMapReadyCallback;
  import com.google.android.gms.maps.SupportMapFragment;
  import com.google.android.gms.maps.model.LatLng;
  import com.google.android.gms.maps.model.MarkerOptions;
  
  public class home extends FragmentActivity implements OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks,GoogleApiClient.OnConnectionFailedListener, com.google.android.gms.location.LocationListener {
  
      private GoogleMap mMap;
      GoogleApiClient googleApiClient;
      Location lastLocation;
      LocationRequest locationRequest;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_home);
          // Obtain the SupportMapFragment and get notified when the map is ready to be used.
          SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                  .findFragmentById(R.id.map);
          mapFragment.getMapAsync(this);
      }
  
  
      /**
       * Manipulates the map once available.
       * This callback is triggered when the map is ready to be used.
       * This is where we can add markers or lines, add listeners or move the camera. In this case,
       * we just add a marker near Sydney, Australia.
       * If Google Play services is not installed on the device, the user will be prompted to install
       * it inside the SupportMapFragment. This method will only be triggered once the user has
       * installed Google Play services and returned to the app.
       */
      @Override
      public void onMapReady(GoogleMap googleMap) {
          mMap = googleMap;
          buildGoogleApiClient();
          mMap.setMyLocationEnabled(true);
      }
  
      @Override
      public void onConnected(@Nullable Bundle bundle) {
  
          locationRequest= new LocationRequest();
          locationRequest.setInterval(1000);
          locationRequest.setFastestInterval(1000);
          locationRequest.setPriority(locationRequest.PRIORITY_HIGH_ACCURACY);
  
          LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient,locationRequest, this);
      }
  
      @Override
      public void onConnectionSuspended(int i) {
  
      }
  
      @Override
      public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
  
      }
  
      @Override
      public void onLocationChanged(Location location) {
  
          lastLocation= location;
          LatLng latLng= new LatLng(location.getLatitude(),location.getLongitude());
          mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
          mMap.animateCamera(CameraUpdateFactory.zoomTo(12));
      }
  
      protected synchronized void buildGoogleApiClient(){
          googleApiClient=new GoogleApiClient.Builder(this).addConnectionCallbacks(this).addOnConnectionFailedListener(this).addApi(LocationServices.API).build();
          googleApiClient.connect();
      }
  }
  </code></pre>
  
  <blockquote>
    <p>manifest file</p>
  </blockquote>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.nitctraveltogether"&gt;
  
      &lt;!--
           The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
           Google Maps Android API v2, but you must specify either coarse or fine
           location permissions for the 'MyLocation' functionality.
      --&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  
      &lt;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"&gt;
  
          &lt;!--
               The API key for Google Maps-based APIs is defined as a string resource.
               (See the file "res/values/google_maps_api.xml").
               Note that the API key is linked to the encryption key used to sign the APK.
               You need a different API key for each encryption key, including the release key that is used to
               sign the APK for publishing.
               You can define the keys for the debug and release targets in src/debug/ and src/release/.
          --&gt;
          &lt;meta-data
              android:name="com.google.android.geo.API_KEY"
              android:value="@string/google_maps_key" /&gt;
  
          &lt;activity
              android:name=".demo"
              android:label="@string/title_activity_demo"&gt;&lt;/activity&gt;
          &lt;activity
              android:name=".home"
              android:label="@string/title_activity_home"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.DEFAULT" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name=".Splashscreen"
              android:theme="@style/Theme.AppCompat.Light.NoActionBar"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity android:name=".MainActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.DEFAULT" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <blockquote>
    <p>Logcat</p>
  </blockquote>
  
  <pre><code>2020-03-08 17:19:31.144 28966-28966/com.example.nitctraveltogether E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.nitctraveltogether, PID: 28966
      java.lang.SecurityException: my location requires permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
          at com.google.maps.api.android.lib6.impl.bi.c(:com.google.android.gms.dynamite_mapsdynamite@200475065@20.04.75 (100400-0):26)
          at com.google.android.gms.maps.internal.i.a(:com.google.android.gms.dynamite_mapsdynamite@200475065@20.04.75 (100400-0):139)
          at ch.onTransact(:com.google.android.gms.dynamite_mapsdynamite@200475065@20.04.75 (100400-0):4)
          at android.os.Binder.transact(Binder.java:675)
          at com.google.android.gms.internal.maps.zza.zzb(Unknown Source:20)
          at com.google.android.gms.maps.internal.zzg.setMyLocationEnabled(Unknown Source:109)
          at com.google.android.gms.maps.GoogleMap.setMyLocationEnabled(Unknown Source:112)
          at com.example.nitctraveltogether.demo.onMapReady(demo.java:42)
          at com.google.android.gms.maps.zzak.zza(Unknown Source:2)
          at com.google.android.gms.maps.internal.zzaq.dispatchTransaction(Unknown Source:12)
          at com.google.android.gms.internal.maps.zzb.onTransact(Unknown Source:12)
          at android.os.Binder.transact(Binder.java:675)
          at cg.b(:com.google.android.gms.dynamite_mapsdynamite@200475065@20.04.75 (100400-0):2)
          at com.google.maps.api.android.lib6.impl.be.run(:com.google.android.gms.dynamite_mapsdynamite@200475065@20.04.75 (100400-0):2)
          at android.os.Handler.handleCallback(Handler.java:907)
          at android.os.Handler.dispatchMessage(Handler.java:105)
          at android.os.Looper.loop(Looper.java:216)
          at android.app.ActivityThread.main(ActivityThread.java:7625)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
  </code></pre>
  
  <p>App is getting crashed while accessing this activity, I am trying to access current location through google map api in android studio and using firebase location. Please help me resolve this error, is there any mistake in manifest file or java file. I have written all the required permissions in manifest file but still the app is getting crashed while running. You can also check the logcat for the error.</p>