Cannot set location on Android 6.0.1 Marshmallow

2,652 views
Skip to first unread message

Michał Brzeziński

unread,
Feb 28, 2016, 5:37:22 PM2/28/16
to calabash-android
Hi all,

all my calabash tests were working correctly on Android 5.1, but now I had some break in app development and when I wanted to run them on Android 6.0.1 - everything works apart from setting location. I get this error:

And I am in "London"                                      # calabash-android-0.6.0/lib/calabash-android/steps/location_steps.rb:1
     
Action 'set_gps_coordinates' unsuccessful: The application does not have access mock location permission. Add the permission 'android.permission.ACCESS_MOCK_LOCATION' to your manifest (RuntimeError)
      features
/favorites.feature:20:in `And I am in "London"'

Displayed message is better than the one in older calabash version ('HTTPClient::KeepAliveDisconnected') but it's still not correct in my case. I checked it and even depackaged my apk to check if 'android.permission.ACCESS_MOCK_LOCATION' was set and yes, it was.

The is probably related to how you allow to set mock locations - earlier it was just a general setting in developer options, but in Android 6.0 you have to give permission to specific application. But it doesn't matter if I choose my app or instrumentation_backend, it doesn't work. And after I run the test and enter debugging settings there is no app set to mock location.

Does it work for anyone else with device running Android 6.0? Do you have any ideas how to make it work?

Thanks!

tobias....@xamarin.com

unread,
Feb 29, 2016, 3:31:47 PM2/29/16
to calabash-android
In Android M, you will have to select which application to allow mock location for. This is in developer options. We could probably introduce it automatically to Calabash.

In Xamarin Test Cloud, this is done automatically. 

Michał Brzeziński

unread,
Feb 29, 2016, 5:05:13 PM2/29/16
to calabash-android
Yes, as I've written (apparently not clearly enough) I've done it. But still it doesn't work for me. And I'm afraid that the problem is the way you need to approve specific application to mock location in Android 6.0. Because of that I would be grateful if anyone could confirm if he/she can make mocking location work with Calabash on Android 6.0 at all.

I suspect what may cause the issue: when you set mock location for specific app and run calabash test, it installs app again, even if it's already installed and it didn't change. Probably that erases setting for mock location as previous "app instance" is no longer there and you should grant permission to newly installed "instance". Which is pretty hard as tests are run immediately afterwards.

tobias....@xamarin.com

unread,
Mar 23, 2016, 12:18:35 PM3/23/16
to calabash-android
Alright. I have added auto-setting of this for applications after installation. Please try 0.7.3.pre1 :)

tobias....@xamarin.com

unread,
Mar 23, 2016, 12:29:13 PM3/23/16
to calabash-android
Or rather 0.7.3.pre2

Michał Brzeziński

unread,
Apr 22, 2016, 8:42:12 PM4/22/16
to calabash-android
Sorry for slow response, but the good news is: it works (I'm using version 0.7.3). Thanks a lot for your help, I appreciate it! :)

Matt Wade

unread,
Oct 20, 2016, 1:17:15 AM10/20/16
to calabash-android





pls my infinixx mock location isnt working , what do i do
Reply all
Reply to author
Forward
0 new messages