views:

33

answers:

2

Hello All!

I have an android application that runs well on my emulator, but when i deploy the .apk to a real phone, it works for about 4-5 minutes and then unexpectedly crashes. Is there anyway I could get a stack trace or more helpful information to show up on the android when it does this? Any particular way to get a log?

And also, what is the best practice for unit testing on android?

-M@

A: 

Do you have an actual phone you can test on? You can get logcat output from a real phone by connecting it with a usb cable.

Is the android version on the phone the same as the emulator you are running? Perhaps that could explain the difference between emulator and phone behavior.

As far as unit testing, Android has decent support for unit testing - even though they have to be run under dalvik on an emulator. See this answer for some info on the basic framework capabilities + an add on framework called Robotium: http://stackoverflow.com/questions/2047261/using-android-test-framework

Stan Kurdziel
+1  A: 

See this question for info on unit testing options.

If you have physical access to the phone, you can debug on it via a usb connection. Just connect the phone to your computer with a USB cable, then eclipse should see it as a possible deploy target.

Otherwise, there are a few solutions for capturing error reports. With Android 2.2 and later, you can request to receive error reports for deployed apps. Someone had a library with a similar solution for pre 2.2 apps, but I can't seem to find it atm.. will update if I do.

Edit: found it, remote stacktrace.

Mayra