简体   繁体   中英

LocationServices.API is not available on this device

I'm calling a location service api from my android device, the application has my location access but when i run my app, I get the following error

    com.google.android.gms.tasks.RuntimeExecutionException: com.google.android.gms.common.api.ApiException: 17: API: LocationServices.API is not available on this device. Connection failed with: ConnectionResult{statusCode=SERVICE_INVALID, resolution=null, message=null}
        at com.google.android.gms.tasks.zzw.getResult(com.google.android.gms:play-services-tasks@@18.0.1:3)
        at com.innoviti.sroconnect.MainActivity.lambda$getCurrentLocation$13$com-innoviti-sroconnect-MainActivity(MainActivity.java:648)
        at com.innoviti.sroconnect.MainActivity$$ExternalSyntheticLambda11.onComplete(Unknown Source:2)
        at com.google.android.gms.tasks.zzi.run(com.google.android.gms:play-services-tasks@@18.0.1:1)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: com.google.android.gms.common.api.ApiException: 17: API: LocationServices.API is not available on this device. Connection failed with: ConnectionResult{statusCode=SERVICE_INVALID, resolution=null, message=null}
        at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(com.google.android.gms:play-services-base@@18.0.1:3)
        at com.google.android.gms.common.api.internal.ApiExceptionMapper.getException(com.google.android.gms:play-services-base@@18.0.1:1)
        at com.google.android.gms.common.api.internal.zag.zad(com.google.android.gms:play-services-base@@18.0.1:1)
        at com.google.android.gms.common.api.internal.zabq.zaE(com.google.android.gms:play-services-base@@18.0.1:7)
        at com.google.android.gms.common.api.internal.zabq.zaD(com.google.android.gms:play-services-base@@18.0.1:2)
        at com.google.android.gms.common.api.internal.zabq.zai(Unknown Source:0)
        at com.google.android.gms.common.api.internal.GoogleApiManager.handleMessage(com.google.android.gms:play-services-base@@18.0.1:58)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:223)
        at android.os.HandlerThread.run(HandlerThread.java:67)

Android skd Version: 30 device: Plixel 3 XL (virtual)

what could be the cause and how do i resolve this?

Just go to the Emulator controls (Three dots menu) and in the Location tab, pin any location in the map and click Set Location.

Then verify if you received the location you were expecting in your app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM