How to debug app on two devices/emulators? - android

I want to debug communication between two Android apps. I have Android Studio 3.0.1.
I don't understand how to start up two instances of the app.

Technically, DipendraSharma's answer is wrong.
You can't watch the logcat for two devices at the exact same time, since you can't have two active instances of logcat at once (there is a post about this somewhere, but I can't find it). However, you can launch the app on as many devices as you have available at once, and change between the devices tab in the logcat window. Just like you'd select multiple items in i.e. a directory, you pick the devices you want. Press CTRL (or the equivalent on a different keyboard) and press the devices you want. Example:
Then, like normal, press launch and after a short while of compiling and launching, it'll show up on both (or however many devices you picked). There is going to be a delay between the nth and the n+1th device in terms of launch.
Now, open logcat. You'll see this:
The dropdown with the device allows you to change the current device you're debugging and can see log info about. Change this as you need.
So yes, you can debug on multiple devices at once. This also applies to emulators. And they mix, so if you want to test on two emulators and two real devices, simply pick the ones you want and it'll launch on all the devices.
For emulators, you can debug as many at once as your computer allows you. For real devices, you can debug as many as you have USB ports for.

You can debug communication between two apps by:
1- Opening both Android Studio projects of course in two different windows.
2- Running each app on a separate device/emulator.
3- Attaching the debugger from each project to the relative app instance.
4- Set up break-points and debug!

Related

debug multiple device simultaneously in android studio

I made one App based on Client-Server programming. I can run that App on multiple devices simultaneously, now I want to debug that App in multiple devices simultaneously so I can check the flow of both client and server simultaneously.
Is it possible in Android studio?? If yes then How can I achieve that??
You can do it by creating multiple launch/debug configurations and assign them the same module. Then just run debug each configuration on different device.
I believe you can start multiple instants by ctrl selecting your devices in the 'Deployment Target Options' pane.
There's annotation prepended in the 'Run' pane on which device is outputting... [DEVICE]-[DEVICE_NAME]-[SERIAL_NUM]

Using the same USB device with two apps on Android

I have developed two applications that use USB host. The second application mimics the functionality of the first, its just slightly different for testing purposes.
The first application works with USB perfectly, but the second one never asks the user for permission and therefore USB doesn't work. I've checked the manifests and I cant see a problem.
Surely two apps can use the same USB device independently?
Will post code if needed - thanks

Running debug on two separate devices in Eclipse

I have 2 Android devices connected to my computer.
I need to debug them both at the same time since I am sending data back and forth between them.
When I set them both to debug mode it will only stop one at a time.
I can't stop the "sender" immeditaly after the send and then debug the "receiver". It just doesn't like it!
I really need to be able to run two completely sessions.
I tried opening a new Eclipse window but it doesn't help.
Any stops I put apply to both and if any device is in debug mode then it applies to both instances.
Try using two machines. as the debug port both of them are trying to connect to is the same for a single instance of eclipse.
Unfortunately, I don't think that it's possible to debug multiple devices on the same computer using Eclipse, at least for now.

Cannot select my Android client in DDMS perspective of eclipse

I want to check my program code for time consuming operations. I thought DDMS is the best tool to achieve that.
However, I cant see Threads, Heaps and so on. It tells my to select a client. But I dont know where other than the Devices Tab, which doesnt take effect.
What do I have to do? Is there maybe smth wrong with my ADB setup (But LogCat works fine)?
Thanks!
Looking at the screen shot, you have the device ("emulator-5554") selected. You need to click on your application from the list of processes.
For example, if you click on "com.android.music", you will see information about the Music app.
Note that, on a real device, you must mark your application as "debuggable" or it won't appear in the list at all (on an emulator, all apps are debuggable). See the Developing on a Device page for details.

my android app runs fine in the emulator, but when i publish it it's wrong

i have an app that has a few checkboxes in the settings and then compiles a remote sql based on the checkboxes selected. i ran it in the emulator and it's fine. but then i exported it and published it as an app, and the same checked boxes aren't being passed correctly. i wonder if it's a caching issue or something. tried deleting the apks a few times and republish but to no avail. i "fake-edited" the source java and then export again, still no difference.
i'm kind of new to eclipse but is there a force build option? i only see build-automatically option under project but not sure how i can make sure that the apk exported is the same as run in the emulator
edit the emulator is version 1.5, and my phone is nexus one running 2.1- not sure if that makes a difference
thanks
As Jim mentioned, always make sure you test your app on the same version emulator as you intend to use it. If it's going to be put on the Market, then make sure you test it on several versions. For example, test on at least v1.5, v1.6 and v2.1. Make sure you use different screen sizes as well for each of these; that's not going to be your problem here, but it will show you whether you've coded your XML files properly.
Another thing you can try is to enable your phone to output log messages, and then you can see if something odd is happening on your phone. I don't have a phone with v2.1, but according to the emulator, this is where that option is: home screen -> menu -> settings -> applications -> development -> enable USB debugging. Once you've done that, restart Eclipse, plug your phone in, and you should start seeing log messages. Restarting Eclipse isn't always needed, but LogCat sometimes gets confused when you've got multiple emulators/real phones trying to output debugging messages. (If you don't know how to enable LogCat, see this other answer.)

Categories

Resources