Enable Mock Locations in Android Marshmallow
Solution 1
If you use the Mock location permission:
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
Then you will be able to select your app by Setting >> Developer Option >> Select Mock location app
Solution 2
I was facing the same problem. Even though my app's manifest file (debug build) had the required permission (ACCESS_MOCK_LOCATION), the Select Mock Location app showed no app in the list.
Solution:
I started my application, pressed the home button (to send my app's activity to the background), and then navigated to Settings -> Developer Options -> Select Mock Location App. My app was now visible in the list.
minh2611
Updated on March 22, 2020Comments
-
minh2611 over 4 years
I cannot get mock locations to work in Android Marshmallow. I have installed app in Android 6.0 . Now, When I want to set mock location for this app by following option.
Setting >> Developer Option >> Select Mock location app
I can not see any Application to select.
Has anyone had success enabling mock locations under Marshmallow?
-
xiaomi almost 9 years@DuannistonCardosoCabral If you add this line into your manifest (debug build), then you can select the application which will use mock location.
-
minh2611 almost 9 yearsHi @xiaomi , I add this line to use ACCESS_MOCK_LOCATION but it is not working, In the Setting >> Developer Option >> Select Mock location app . No app appear for me to choose . Can you have another way ?
-
xiaomi almost 9 years@minh2611 strange, I tested with the emulator and a nexus 5 without trouble :/
-
minh2611 almost 9 years@xiaomi, I tested on S6 device, I can not add it even I added 4 permission that android.permission.ACCESS_MOCK_LOCATION android.permission.ACCESS_COARSE_LOCATION android.permission.ACCESS_FINE_LOCATION android.permission.ACCESS_LOCATION_EXTRA_COMMANDS. I don`t know how I can select app on etting >> Developer Option >> Select Mock location
-
xiaomi almost 9 years@minh2611 Is your build the debuggable build?
-
minh2611 almost 9 years@xiaomi , I test for mock location function , but I see that, It can not run .
-
Bill Mote about 8 yearsYou have to run it and let it fail once before it's in the list of selectable applications. Super-sucky for testing as the framework uninstalls the test app at the end of the tests :)
-
LoveForDroid about 8 yearsHow to programmatically detect whether mock location app has been selected in Marshmallow?