Whether i should should use sysout or Log.x en-order to debug an android project. I think both are writing to file. Me, commonly using sysout and use filter in LogCat to get it easily. But most of the tutorials and sample i see it is mainly using log.x
What is its basic difference? any link or tutorial for that? Which is better to use?
Thanks
Hai Labeeb Brother, You can refer this from andbook which may download from the following site using your facebook account itself
http://www.docstoc.com/docs/57705463/Android
if downloaded that book, pls go through the page number 45 and 46. this will give clear idea brother.
refer those pages of the book ,in the following image brother
In general, it's a good practice to avoid using sysout (even when using standard java development).
Using the Log object gives you support for tags and priorities.
Logcat has built-in filtering capabilities on tags and priorities.
There's also a performance gain when using the Log object properly, as writing a lot of info to the output stream can be an expensive operation.
The Log object also exposes an isLoggable that allows for selective logging (depending on tag and priority).
Information on viewing the log output can be found here : http://developer.android.com/guide/developing/tools/adb.html
Information on the Log object can be in the Android Developer Reference under android.util.Log
Some options for viewing your log output on your android phone can be fuond with the following Google query : android logcat viewer phone
Related
I just finished my last app and after intensive testing on android studio no bugs or errors pooped up.
But when I use my phone for some time and try to check my app it crashes, and error pops up.
Is there a way to find out the stack trace od that error? specially since its not connected to my PC.
You can integrate tools for analyse, like:
Crashlytics
So you have a dashboard and can setting a e-mail for warning.
You can use different options:
Store logcat file in Internal memory as txt file. This will be best solution since it will provide all the necessary information of pre-conditons for the crash
Implement crashanalytics like Hockeyapp
Use remote debugging. Refer this official document for more info
You can find more details for approach 1 & 2 at: remote logcat - Android Studio
I've seen plenty of ways of getting system logs in Android with logcat and the like, but not so much about app logs (except for the usual USB + adb solution).
My B2B Android app produces useful logging created with Log.i calls. Whilst in Studio these are very useful for debugging, it would also be useful to get these from customer's installs when things go wrong, i.e. from a release build out in the wild. Customers are generally not techies so getting logs via adb isn't really an option.
Is there a way within the app code itself to grab all the log contents?
Perhaps the SDK provides a way to do this?
I could then send that to my server or by email. I'm thinking it'll be useful for my customers to just hit a button so I can get an instantaneous snapshot of what is happening in the app.
Thanks in advance
UPDATE
There doesn't seem to be a way to do this, aside from writing to a file and sending that file. Which I guess is a good a solution as any.
Two other interesting ones that have come up are:
Firebase (from Mohammed's comment) - can log events:https://firebase.google.com/docs/analytics/android/events
Instabug
we can write write logs to file using java.util.logging.Logger API.
How to write logs in text file when using java.util.logging.Logger
Check out here for writting crash log to a file
Obviously with code, errors can occur anywhere. So without having try/catch blocks all over the place (which as I understand it is major overhead) how do I allow errors to bubble up to the application level and then handle them there? Or at the very least, record the error somehow for troubleshooting? I found information on an product called ACRA, but the setup instructions are geared for Eclipse projects. I am using Mono for Android in Visual Studio 2010.
That's a bit of an "It depends" question.
The appropriate handling of an errors is going to depend on what the recovery strategy needs to be, how much information you want the user to see etc.
I wouldn't worry how many Try/Catch blocks you use - just use them wherever you need to handle an error that gets thrown - if they're everywhere, your strategy is probably wrong.
It terms of logging and later interrogation, you can log caught errors using the Android.Util.Log class.
These can be interrogated (provided you're debugging on your own device) using Logcat.
There's some more info on logging and Logcat here.
Found this project that writes crash info to google docs. Android Crasher
I installed the example SampleSyncAdapter from the sdk into eclipse--it runs in the emulator--e.g, if i go to Settings>>Account & Sync, I do see the SamplesyncAdapter Account--but i can't log in when i select it--the Google documentation is next to useless in terms of orienting developers--what should I enter to log in? How do I run the application--I want to run it in debug to walk thru the code.
UPDATE: i found answer--if anyone is having same issue:
http://groups.google.com/group/android-developers/browse_thread/thread/ac875a97679122f0
Refer to the reply by Megha in the above thread--also, refer to the class NetworkUtilities if you are trying to understand how the external server is contacted for the update--in my case I will alter this class to point to a local tomcat/servlet to experiment.
It sure is hard to understand why the Google Developer Reference site does not contain the information in the above thread--which was supplied by a google employee over a year ago.
yes, that link is interesting, there you will find information about the serverside, but here you have other interesting links bout it:
this is the documentation in developer.android.com :
http://developer.android.com/training/id-auth/custom_auth.html
here's an article where you will also find information about the
components of the Android application:
http://www.techrepublic.com/blog/app-builder/breaking-down-googles-samplesyncadapter/1037
and here's other interesting article here on StackOverflow :
How do I use the Android SyncAdapter?
How can I read the error log applications make? Is there any software which reads the error log from the handset and displays it?
I don't want to debug the app using eclipse, I'm looking for a handset based error log viewer.
There are a number of free applications in the Android Market which will collect the device log.
One which looks promising is Log Collector, not least because it is open source. You can find it on Google Code here and on androlib.com here.
Here's another Log Collecting app produced by the creators of Locale.
I quite like the one I wrote ;-)
It's called SendLog
http://l6n.org/android/sendlog.shtml
Alogcat seems OK. It's a bit verbose, though.