Android: How to get logging information if device freezes / hangs? - android

I have written an app and on some devices, using the app freezes the system. My main problem is, that I do not get any log information, because as soon as the device is frozen, logging completely stops and obviously the crash-reports normally would be generated after the crash, which does not work, because the device is frozen.
I have attached the device to my laptop via adb (via USB) and logcat everything, but the logging just stops as the device freezes. I have also checked all possible log locations (I used this reference) and could not find anything.
Since the app crashes only on about 10% of all devices (the devices are identical and have the same firmware) I need to test the app on the device and cannot use the emulator. However if the app crashes, I can relieable reproduce the crash using adb monkey. On the other 90% adb monkey won't crash the device.
Is there anything else I can log / test / check? Is there a way to get a memory dump, once the device is frozen?
Although I don't think this is relevant: The device is a XORO 9718DR tablet and the device is rooted. The app is written by myself and not available in the market. It mainly uses only Buttons, TextView, ImageView, HttpClientConnection, Threads, AsyncTasks and other "normal" Android stuff. It even does not use the webview.

Use DDMS to trace heap memory here.
In your manifest file put debuggable=true. Build your app and install it on your device, run DDMS. Select your app from the list, and enable Heap from the toolbar button.

Related

Android: is there a way to dump crash logs locally on test device with no computer connected

I'm experiencing pesky SIGSEGV faults in my Android app. They are inconsistent to reproduce and mostly happen after my app has been restarted a couple of times. The problem is, when the app restarts, Android Studio stops showing the logs, making it very hard for me to figure out what the issue is. When I restart the app using the Android Studio restart button, it loads a fresh install of the app onto my phone, which is an issue because the errors don't seem to happen on very fresh installs.
My question is: can I somehow have Android Studio still show the live logs WITHOUT reinstalling the app every time, OR can I run the app without being connected to any PC, and dump a crash log file locally to the phone when the app crashes, so that I can open the logs later on?
Filtering logcat
The problem is, when the app restarts, Android Studio stops showing the logs, making it very hard for me to figure out what the issue is.
It sounds like the logcat in android studio is filtering by application. You can change it to no filter and set the text filter to your application's id. This way the logcat will not be cleared once the application process dies/restarts.
Extracting the tombstones
Since this is an Android native crash it will not be sent to bug capturing software such as Crashlytics or Bugfender etc.. you can pull the tombstone[s] directly from the device with adb.
adb bugreport bugreport.zip
Once extracted, the tombstones will be under path /bugreport/FS/data/tombstones/.
Typically 10 tombstones will get saved to device storage but will get overwritten by earlier native crashes once the limit to the number of retained tombstones has been met.
Android documentation: Using bugreport
Android documentation: Debugging tombstones

Run your app in Android Studio by connecting it to Actual Device or through APK

Is it better to test your application via USB (directly connecting your phone to the Android Studio) or by downloading the APK version of your app. I've been using emulator and it's really time consuming because it keeps lagging on my laptop. I wanna know which is faster and safer?
Connecting your phone via USB is always a more reliable and faster option (even if u don't consider the time it takes to copy and paste your APK file from pc to phone) You can also do a activity restart rather than restarting whole app this way which is less time consuming. You can even specify a certain activity to launch for testing. It also provides lots of Monitoring options like device monitoring, Network Monitoring, Database Inspection, Layout Inspection and so on.

Getting app logs off of a Samsung Galaxy S6

I do testing on app that I download from Jenkins as a .apk file. I have Android Studio and I have gotten as far as connecting my Samsung galaxy S6, setting it to debugging mode and I can see a bunch of device logs coming up at the bottom of my Android Studio screen.
What I cannot figure out is how to see the logs for the app I am testing. I have tried to filter the logs by using the app name. Do I need to filter the logs using a specific file name? Maybe the file used to install the app? Is there an easy way to get the app logs from my device that I am not seeing?
You need to ensure that:
This is the debug version of the app.
Proguard isn't set up to strip out certain logs.
ADB Integration is enabled.
Sometimes, you have cycle through the USB options (For example, my LG phone needed to be in PTP mode before Android Studio picked it up)
For obvious security reasons, most apps don't want the public to access their logs.

App won't launch on the device

No matter what app I try, it won't launch on the device. It works perfectly on emulator, but when I try to launch it on the device, it'll get uploaded & installed and then "Starting activity on device " appears and nothing happens - it just sits there and does nothing. When I repeat the process, eventually it will launch (but it has to be repeated like 5-10 times), but all those activity launching processes seem to remain active, which causes my phone to lag. I tried resetting adb, reinstalling Google USB drivers, nothing helps. I have a rooted phone, and custom ROM (it's called Darky's ROM 10.2) - could that be a problem maybe?
Sometimes it takes a long time to install and run, and ADB times out. Go to preferences in Eclipse, then to Android -> DDMS -> ADB connection time out (ms), and set it to something like 30000
You can try many things:
Compile and run a sample app on handset, does it run or not? If it doesnt then there may be a compilation environment (your PC) issue, signing or something else.
Download a free app from marketplace and see if you can run it.
Is this a standard Android phone or a rooted one? if its rooted then try on a standard handet.
Before installing do "adb kill-server" and then "adb start-server" to restart the adb. This may not be useful, but, just in case.
After installing the app, can you see it in Settings -> Applications -> Manage Applications menu?
Try a hard power cycle, by removing the data cable/charger and removing the battery for 10 seconds.
Also ensure that the emulator had the same screen dimensions as the handset you are testing on.
Attach Logcat and see what shows up there.
These tests will give you better idea of what is happening.

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.

Categories

Resources