Set GPS location in Android Studio while debugging app
Solution 1
In the end, I did this using Android GPS Emulator, a Java program which runs on the computer and sends location updates over ADB.
Solution 2
1- go to plugins and look for GPS emulator, and install it then start the emulator from Tools--> Android---> Android device monitor then find you desired location long and lat (search google for any website that gives you the lang lat for your city, google: get lang lat websites) and send them to the android emulator.
2- or fastes way if android emulator is running On the Right Side of Your Android Emulator Where (Power Button ,Speaker , Camera etc Sign are given Find Three Dot Sign(...) at the last of that column. click on that then Click on location and Set the Latitude and longitude
Solution 3
You should install application that can set fake gps location like https://play.google.com/store/apps/details?id=com.fakegps.mock run it first, then run your app.
Moshe Katz
#SOreadytohelp I am currently a Computer Science graduate student (Ph. D. seeking) at the University of Maryland. I do a lot of programming (primarily web application development) for small businesses and nonprofits. In school, I focus mostly on security and context-aware systems, and I have also worked on counter-terrorism applications. You can find me most days in PHP and/or C#, but increasingly in JavaScript with a focus on Rich Internet Application areas (knockout.js, durandal, breeze.js, etc) and WebRTC.
Updated on June 04, 2022Comments
-
Moshe Katz almost 2 years
(Preface: I have already seen this question, but it doesn't address setting the location while debugging the app. Opening "Android Device Monitor" closes the ADB connection to the debugger itself.)
I am trying to debug an application that monitors for location changes. The issue that I have is that I can't figure out how to run the debugger and set the location using
adb geo fix ...
at the same time.I have tried running the command in the Android Studio "Debug" -> "Console" tab, but it doesn't seem to do anything.
How can I set the location while still remaining connected in the debugger?
-
CommonsWare over 9 yearsHave you tried the emulator console (telnet into
localhost:5554
)? -
Moshe Katz over 9 years@CommonsWare I was afraid that doing that would mess up the connection into Android Studio also, but it does seem to work. It's a shame that there's no built-in way in Android Studio.
-
-
Moshe Katz over 9 yearsI can't do that, because I need to have the location change several times while my app is running in order to test it properly.