6

I'm new on Android programming, I try to use the new Location Service for getting the user position, to do this i follow the official android developer guide but I don't understand why I'm not able to import LocationRequest in my fragment class.

import com.google.android.gms.location.LocationRequest; 

here is my Gradle app file:

build.gradle

 ..
   compile 'com.android.support:appcompat-v7:24.2.1'
   compile 'com.android.support:design:24.2.1'
   compile 'com.android.support:palette-v7:24.2.1'
   compile 'com.android.support:cardview-v7:24.2.1'
   compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
   compile 'com.google.code.gson:gson:2.6.2'
   compile 'com.android.volley:volley:1.0.0'
   compile 'com.android.support:support-v4:24.2.1'
   compile 'com.google.android.gms:play-services-maps:9.8.0'
 }

and this is what I include in my Manifest file

AndroidManifest.xml

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

what i do wrong?

Zoe
  • 27,060
  • 21
  • 118
  • 148
BitRulez
  • 729
  • 2
  • 8
  • 18

5 Answers5

18

add dependency 'com.google.android.gms:play-services-location:9.0.2'

prat
  • 284
  • 1
  • 3
3

Add this line when importing in the main activity

import com.google.android.gms.location.LocationRequest;
phuclv
  • 37,963
  • 15
  • 156
  • 475
1

Import these dependencies in your build.gradle file....

implementation 'com.google.android.gms:play-services-location:17.1.0'
implementation 'com.github.niqo01.rxplayservices:rx-play-services-location:0.4.0'
Mukul Raghav
  • 349
  • 2
  • 5
0

Before you can import com.google.android.gms.location.LocationRequest; in to your activity you need to add com.github.niqo01.rxplayservices:rx-play-services-location:0.4.0 as a library dependency in the project structure.

Julian Heinovski
  • 1,822
  • 3
  • 16
  • 27
Patrick
  • 1
  • 1
0

Solved it by adding "implementation 'com.github.niqo01.rxplayservices:rx-play-services-location:0.4.0'" in the graddle