android error feedback device - android

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.

Related

Is it possible to see output from log cat without having the app source code?

I have an app installed on my device.
An app that I developed, but I haven't got the source code anymore.
Is it possible to attach log cat to this app?
yes you can, just enable usb debugging on your android device, and plug the device where you have the application installed on it, by that, you will see all the logs on logcat.
Depends if you've left logs in the code. If you did, the easiest method would be probably going into your Android Studio and checking you Android Monitor tab. You can switch devices / applications there.
If you don't have any logs and your question actually means you want to add some logs in, then I'm afraid you can't reliably do that.

Debugging Android Apps without USB or root

I'm currently developing a small android app which communicates with a FTDI chip over USB so I can't use logcat to get the logs live. Unfortunatly the Android device is a Galaxy Tab 2 with Android 4.1.2 which I'm not allowed to root. That means adb-wireless won't work too. And because it's just a small app setting up a bugtracker system like ACRA seems a bit oversized.
Is there another way to get the logs of my app?
Many thanks
I can't think of any "live" logcat output, but you can view your Logcat Output (which is Buffered) via adb logcat. Test the things in your app you want to do or to get the Error you try to solve, then connect the USB to a Computer running adb and dump the Log.
More information for the logcat Command can be found here
You can make a utility function that opens an HTTP connection and writes to a web server.
This adds a little overhead to your application, but works fine to get log info.
Easy to implement, no rooting required!
Or you could write a little service that runs a web server that responds to requests with a dump on logcat (or a tail or logcat or something).
It might even be possible to write a shell script that uses curl or wget to do this (that is send get requests to a webserver in order to pass logcat output), but you might need to install them, which in turn you might need root for, so... maybe this wouldn't meet your needs.
I guess it might even be possible to create a network share on your workstation, mount it on your android device and just redirect logcat output to a file on the share. But I didn't try it - let me know if you do!
You could use apps like Logcat or others alike, which will give you the same output as your IDE Logcat console.
You can turn on the logging, do your stuff in your app, and return to the logcat app to check out the log, mail it to yourself etc.
I did a little bit more research and it seems that there's no possibility to read the logs easily without having root rights. You're able to read the logcat output using bugtracking libraries like ACRA in your Android app, but it's a lot more effort to include them and analyze the logs.
I'm going to develop on my own (rooted) tablet with adb-wireless now.

How to debug when application works fine in emulator but fails in actual phones?

How can i debug when application works without error in emulator but force closes while doing SQLite operations on some screens?
Connect your phone to your dev machine
Make sure the emulator is not running
Open a command prompt and run adb logcat
Use application on your phone and trigger the error
Review the resulting stack trace in the logcat output
You can also view the logcat output in Eclipse via the debug or DDMS perspective.
You should connect the phone to your development machine and look at Logcat (or use the debugger) to see what is going on in the stack trace. You can also install an app (like CatLog) on the phone to view the log.
You just connect you phone and use debugger. When it is open just choose your phone...you can use and logcat too...
Everyone else commented about the technical tools available, so I'll try to explain the process we have with our app. Our app is pretty widely used, so we have a bunch of different devices to consider.
Create a beta group. There are a lot of devices, and it's impossible to test on all of them yourself unless your company has very deep pockets and you have a lot of time to test. Get a group of users together who are ok with things breaking, and ask them to beta test.
Look at what's different. This one seems obvious, but it's surprising how often this trips us up. If an app isn't working on certain devices, what's different about those devices? We once had a bug that only occurred when the app was in landscape mode, so we saw it mostly on devices that default to landscape mode. When you're trying to find the cause of a bug, ask yourself what the difference is between the scenario where the app doesn't work and the scenario where the app does work.
Use the tech available. Sometimes, the last two don't catch all the problems. Sometimes, you get a weird edge case. We had 2.3 devices that didn't implement a deprecated method-- even though the method was deprecated in 3.0. For whatever reason, they didn't implement the method and left us without its replacement, so we had to use a backwards compatibility package. But the only reason this came to light was because we got access to the logcat reports from users who experienced the bug. Moral of the story: manufacturers do weird stuff.
You're not going to be able to catch everything. There are just too many subtle and non-sensical differences. But (especially with beta testing) you should be able to catch 99.99% of the problems before they happen.

Why does Android DDMS show logs for a few hours, but then fail?

I use IntelliJ IDEA to write Android apps, and use the DDMS Windows application to view the Android logs (separate from the IDE). It works fine, but after a seemingly random period of time, the logs vanish, except for one line of log, which gets overwritten with incoming logs. I have to shut it down and restart it, which combined with the delays of deploying an app to a device over ADB to debug and test is pretty tiresome.
Is this a known issue with DDMS? Is there anything I can do to make it work consistently without breaking itself?
Are there any other Android log viewing applications for Windows that work better? I'm not very fond of the IntelliJ IDEA one. My favourite is actually CatLog on Android itself, but on a small-screen device it's not a great experience.
It's not about the time, but number of lines being recorded. As Dave C said in the comment, just clear the log and it will be fine
Have you tried looking at "Why doesn't LogCat show anything in my Android?"? The top voted answer may solve your problem

App is not stable

Ive developed some app for Android,
the Weirdthing that on the emulator it's pretty stable, but when i tryied on real device of a friend(nexus), it crushes times to times, cant finger on a specific case when exaclly it happens.
i realy want to distribute the app asap, but i cant find any leaks in my emulator.. what I should do? how can i debug my app and find the reasons for it to get crush on real device..
Thanks,
Idan
Plug the Nexus One into your PC, and view the stack trace when the app crashes. If you want to know why your app is crashing you've got to get to those stack traces.
You can tell your friend to download http://code.google.com/p/android-log-collector/ from the Android market and run it right after a crash. It'll give him an option to share his recent logcat in various ways.
Some things may be private to him (like what programs he has ran) so he can email it to himself and forward you just the parts about your app.

Categories

Resources