Appium 1.9.1 issues setting location on Android Device


#1

While trying to set the location on the android phone, after upgrading to 1.9.1 form 1.7.2 I started seeing this error:

2018-10-18 01:34:19:580 - [HTTP] --> POST /wd/hub/session/49162b76-b896-46d8-bc32-da8bd4dbda0a/location
2018-10-18 01:34:19:580 - [HTTP] {"location":{"altitude":10,"latitude":42.2980217,"class":"org.openqa.selenium.html5.Location","longitude":-71.219236}}
2018-10-18 01:34:19:581 - [debug] [W3C] Calling AppiumDriver.setGeoLocation() with args: [{"altitude":10,"latitude":42.2980217,"class":"org.openqa.selenium.html5.Location","longitude":-71.219236},"49162b76-b896-46d8-bc32-da8bd4dbda0a"]
2018-10-18 01:34:19:583 - [debug] [ADB] Running '/Users/jenkins/build_tools/android-sdk-macosx-r24.4.1/platform-tools/adb -P 5037 -s 324f4e3857563398 shell am startservice -e longitude -71.21923 -e latitude 42.29803 io.appium.settings/.Locat
ionService'
2018-10-18 01:34:19:738 - [debug] [ADB] Running '/Users/jenkins/build_tools/android-sdk-macosx-r24.4.1/platform-tools/adb -P 5037 -s 324f4e3857563398 shell am broadcast -n io.appium.settings/.receivers.LocationInfoReceiver -a io.appium.setti
ngs.location'
2018-10-18 01:34:20:610 - [HTTP] --> GET /wd/hub/status
2018-10-18 01:34:20:611 - [HTTP] {}
2018-10-18 01:34:20:611 - [debug] [GENERIC] Calling AppiumDriver.getStatus() with args: []
2018-10-18 01:34:20:611 - [debug] [GENERIC] Responding to client with driver.getStatus() result: {"build":{"version":"1.9.1","git-sha":"f9ee7d068e14f10729f88ebd85db802c2e8ac21a","built":"2018-09-20T18:14:29Z"}}
2018-10-18 01:34:20:612 - [HTTP] <-- GET /wd/hub/status 200 2 ms - 151
2018-10-18 01:34:20:613 - [HTTP] 
2018-10-18 01:34:21:770 - [debug] [W3C] Encountered internal error running command: Error: Cannot parse the actual location values from the command output: Broadcasting: Intent { act=io.appium.settings.location flg=0x400000 cmp=io.appium.settings/.receivers.LocationInfoReceiver }
2018-10-18 01:34:21:771 - [debug] [W3C] Broadcast completed: result=0
2018-10-18 01:34:21:771 - [debug] [W3C]     at ADB.callee$0$0$ (/Users/jenkins/build_tools/scripts/node_modules/appium/node_modules/appium-adb/lib/tools/adb-commands.js:920:11)
2018-10-18 01:34:21:771 - [debug] [W3C]     at tryCatch (/Users/jenkins/build_tools/scripts/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
2018-10-18 01:34:21:771 - [debug] [W3C]     at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/jenkins/build_tools/scripts/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
2018-10-18 01:34:21:771 - [debug] [W3C]     at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/jenkins/build_tools/scripts/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
2018-10-18 01:34:21:771 - [debug] [W3C]     at GeneratorFunctionPrototype.invoke (/Users/jenkins/build_tools/scripts/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
2018-10-18 01:34:21:771 - [debug] [W3C]     at <anonymous>
2018-10-18 01:34:21:777 - [HTTP] <-- POST /wd/hub/session/49162b76-b896-46d8-bc32-da8bd4dbda0a/location 500 2196 ms - 1643

Code to duplicate

Location useLocation = new Location(42.2980217, -71.219236, 10);
appDriver.setLocation(useLocation);

This is using Appium Java Client 6.1.0 on a real device


#2

You should either upgrade appium settings helper manually or install [email protected]


#3

Is there a fix for this in 1.9.2?


#4

1.9.2 is not released yet, but it’s fixed in beta


#5

Issue is still reproduced on beta version (1.9.2-beta.2):

8-10-22 16:10:05:568 - info: [debug] [W3C (fa987f2e)] Encountered internal error running command: Error: Cannot parse the actual location values from the command output: Broadcasting: Intent { act=io.appium.settings.location flg=0x400000 cmp=io.appium.settings/.receivers.LocationInfoReceiver }

2018-10-22 16:10:05:568 - info: [debug] [W3C (fa987f2e)] Broadcast completed: result=0, data=""
2018-10-22 16:10:05:569 - info: [debug] [W3C (fa987f2e)]     at ADB.<anonymous> (C:\Users\ihor.hanets\AppData\Roaming\npm\node_modules\appium\node_modules\appium-adb\lib\tools\adb-commands.js:914:11)
2018-10-22 16:10:05:569 - info: [debug] [W3C (fa987f2e)]     at Generator.next (<anonymous>)
2018-10-22 16:10:05:569 - info: [debug] [W3C (fa987f2e)]     at asyncGeneratorStep (C:\Users\ihor.hanets\AppData\Roaming\npm\node_modules\appium\node_modules\@babel\runtime\helpers\asyncToGenerator.js:3:24)
2018-10-22 16:10:05:569 - info: [debug] [W3C (fa987f2e)]     at _next (C:\Users\ihor.hanets\AppData\Roaming\npm\node_modules\appium\node_modules\@babel\runtime\helpers\asyncToGenerator.js:25:9)
2018-10-22 16:10:05:571 - info: [debug] [W3C (fa987f2e)]     at <anonymous>

Code to reproduce:

Location location = new Location(50., 50., 0);
driver.setLocation(location);

#6

Any information on a possible fix?


#7

@mykola-mokhnach I’m too facing the same parse error while getting the location. As like you mentioned, I’ve installed 1.9.2-beta.2. But, still the same issue persists. Can you check and fix it ASAP. It would be helpful for us.

LOG:

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Cannot parse the actual location values from the command output: Broadcasting: Intent { act=io.appium.settings.location flg=0x400000 cmp=io.appium.settings/.receivers.LocationInfoReceiver }
Broadcast completed: result=0, data=""


#8

Make sure that Appium Settings utility is up to date. If not then download and install it manually from https://github.com/appium/io.appium.settings


#9

There was an issue, that geolocation features were broken in the most recent Android OS releases and this has been fixed several days ago, but not published yet


#10

@mykola-mokhnach I’ve downloaded the io.appium.settings and installed the latest 2.9.0 build in device. But still I’m getting the same issue. I’m using android 8. When would I expect the latest changes to be published for this fix? Thanks!


#11

It might an issue with the device itself or its settings. Can you attach the logcat output?


#12

@mykola-mokhnach I’ve attached the logcat logs for Appium settings (io.appium.settings).

11-01 15:50:41.286: D/LocationInfoReceiver(28047): Getting current location
11-01 15:50:41.304: E/GPSTracker(28047): Appium Settings has no access to FINE location permission
11-01 15:50:41.310: E/GPSTracker(28047): Appium Settings has no access to COARSE location permission

After looking into these logs, I just enabled the location permission for Appium settings app. Then I can able to get the location information. This is fine for now. But it would be more fine if the location permission is enabled by default.


#13

@mykola-mokhnach I need one more clarification regarding enable the location using Appium driver? Is there any way to do this? As of now I’m using ADB command to enable the location. But it would be much better if the method is available in Appium.


#14

Appium does enable permissions for settings utility if it is installed not manually (it adds -g flag to adb install command). Although, if the tool is already installed and is up to date, then we don’t touch any other settings or permissions there.


#15

Okay @mykola-mokhnach that is fine. What about enable/disable device location using driver? Is there a way in appium?


#16

No it is impossible to change that programmatically. Although you can try to do the switch in your script directly via Settings UI.


#17

@mykola-mokhnach But it’s possible to run adb command in appium since I’ve seen in appium logs that the adb commands are getting executed to interact with devices. Then why can’t you do enable/disable location with appium since there are adb commands to enable/disable location? Can you take it as a feature request?


#18

What are these commands?


#19

@mykola-mokhnach As of now I’m using the following ADB commands to enable/disable the location in device

CMD_GET_GLOBAL_LOCATION_STATUS = “adb shell settings get secure location_providers_allowed”;
CMD_ENABLE_GLOBAL_LOCATION = “adb shell settings put secure location_providers_allowed +network,gps”;
CMD_DISABLE_GLOBAL_LOCATION = “adb shell settings put secure location_providers_allowed -”;

But if you’re planning to add these chnages you need to check these commands are working for all android versions.


#20

@mykola-mokhnach I’m getting the same parse error again while fetching the location using driver. I’m using fake gps app to mock the location. Once I set the fake location in device using fake gps app, I can’t able to see the output for driver.location().
Any ideas on how to make it work?

I just uninstall the appium settings and reinstalled again (2.9.0), All permissions are enabled. But still no luck.

LOG:

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Cannot parse the actual location values from the command output: Broadcasting: Intent { act=io.appium.settings.location cmp=io.appium.settings/.receivers.LocationInfoReceiver launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } }
Broadcast completed: result=0, data=""