Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Debug two modules at once

I am somewhat familiar with the Android Development environment. Using Eclipse, I have the ability to Debug two/multiple projects at once.

I have not figured out how to do this with Android Studio. I have two modules, a service and activity, that I would like to Debug simultaneously.

Any suggestions?

Thanks.

like image 724
smetanma Avatar asked May 08 '14 16:05

smetanma


People also ask

Why might you create multiple debug configuration for the same project?

If you are working in a team, you might want to share your run/debug configurations so that your teammates could run the application using the same configuration or enable them to remotely attach to the process you are running.

Can we have multiple apps in one Android Studio project?

Yes, it is possible. As the existing answers showed, it's quite straightforward to create additional application module in the same Android Studio project. So I'll try to answer underlying question why anyone might need it. It's certainly not worth it to put multiple completely independent apps in one project.

How do I open two projects in Android Studio?

To open multiple projects simultaneously in Android Studio, go to Settings > Appearance & Behavior > System Settings, in the Project Opening section, choose Open project in new window.

Which tools are used for debugging on the Android platform?

Android Debug Bridge (adb) is a versatile command-line tool that lets you communicate with a device. The adb command facilitates a variety of device actions, such as installing and debugging apps, and it provides access to a Unix shell that you can use to run a variety of commands on a device.


1 Answers

You can debug multiple processes at once, with some limitations.

  • If you have multiple project windows open at once in the same single installation of Android Studio, you can run and debug applications from each of them.

  • If you have multiple modules in one Android Studio project, then you can only debug one of them via the Debug command in the Run menu (which is the usual way to debug an app). If you try to debug (or even run) a second module while the first is running, it will clobber the first one. However, if you install the second module and get it running without using the Run command in Android Studio (i.e. you launch it manually from the device, or in your case, send an intent to start the service), then you can attach to the running process and debug it without losing your debug session in the first module. To do that, use the Attach debugger to Android process command in the Run menu. When you do this, you will see two tabs in Android Studio's Debug window and you can flip back and forth between them.

  • I don't believe you can have two different IDEs (i.e. Android Studio and Eclipse/ADT or two different installations of Android Studio) debugging applications at the same time on the same host machine. They both fight for control of the ADB connection, and everybody loses.

like image 98
Scott Barta Avatar answered Sep 26 '22 23:09

Scott Barta