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.
Related
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!
I have a hobby android app idea that basically just uses Android's sensors and logs them long term for several days (external battery). The sensors needed are in $200 phones, and I can get ones for under $100 if the screen doesnt work.
My question is, is it pretty easy to make an app that starts and loads via debugging, keeps running when disconnected and when I connect I can extract the log file, or would this so be difficult I would be ahead just to spend the extra $100?
As mentioned, turning on USB debugging without the screen isn't possible. You can't enable USB debugging over USB for security reasons, so your only option would be to use hardware commands to put the device in firmware download mode (presumably it will have a way to do that), then load a custom OS which allows USB debugging by default.
Personally I think that's more than $100 worth of work, so I'd just go with the working device. Then you can use it for other stuff down the line.
Alternately, you can probably get a replacement screen for not too much, and for most devices changing the screen is relatively easy. I'd look into that option as well.
The first barrier you may find is that you must activate the Developer Options in the settings and the USB Debugging. And when you connect to the computer, you must accept that cumputer as the Debugger.
I don't know if it's possible to do it without a working screen.
App will keep running & yes you can can extract the log file when connecting again.
But the problem is in the first step. if your screen if not working, then how would you add your workstation as a trusted device in your "display not working device". I doubt if there is such way, because we need to do several things like switching on developer options, usb debugging etc.
I hope you got your answer.
I am trying to learn android development but after running my app through my phone it runs fine, but I can't close it. It doesn't even appear as a running app under apps on my phone settings. It doesn't appear anywhere on my phone but it is running. There doesn't seem to be any kind of stop button in eclipse.
How do I close the app on my phone/eclipse cleanly so I can carry on editing and re-run it?
The only thing I can think of is just unplugging the USB cable but I am afraid of breaking things. ADB feels fragile enough as it is.
I have searched a few answers on this site but they seem to be talking about something completely different.
You may use DDMS. Select process representing Your app on the list in top left window and click stop button You will see above.
Also, if you just re-install the app after some code change, it should re-run...even if you have the app open on your phone!
Hold down the home key until a list of running apps appears. Then just swipe it away :)
If you're truly interested in making an app go away completely then there's a FANTASTIC app called DevDrawer (https://play.google.com/store/apps/details?id=com.owentech.DevDrawer) that allows you to put package names of apps in it that you're currently developing. Trust me when I tell you that it will save you a LOT of time.
I was wondering if there is any way to get any feedback of what's going on behind the scenes when running an app on an Android device. If I use the emulator and eclipse I can see what's happening in the logcat. But I'm making a program with ROS android and it I cannot run it on the emulator. Now my program crashes and I don't know why. Is there any way I can get more information?
Thanks
You can use adb to debug the app on your device. See http://developer.android.com/guide/developing/device.html
I can think of a couple (less than elegant) ways to try and find out what's going on.
1) Display toasts from potential problem areas (Does it have a screen?)
2) Write logs to the SD card (does it have an SD card??)
EDIT
I wasn't thinking clearly... you have to be able to load the program to the device, so you must be able to connect it to your PC. So, as Agarwal pointed out, you can most likely hook it up, run it on the device/robot/whatever and see what happens with the logcat.
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.)