I'm having hard time to find answer in Google to this stupid question.
I come from C# to android development and in C# when my application crush, the compiler shows where exactly my application crush in the code and I can see the values of all the variables.
For now, my app crush and I got no idea where to search the mistake.
Is this possible to have in android Eclipse with GenyMotion emulator this behavior? How?
There is a logging facility on Android called LogCat. You can open it in Eclipse by going to menu Window > Show View > Other... > LogCat.
Any uncaught exceptions will be printed in red color. The filter for your application will be created when you run it.
Is this pissibol to have in android Eclipce with genymotion emulator this behavior? How?
To fix your crash first look at the exception in the logcat then try to understand what exactly that error message. For example : NullPointerException then probably you are trying to access which you haven't initialized.
Now to see variable then use debug feature of the IDE. In eclipse with Genymotion or device you can debug your application then use Ctrl + F6 to trace line by line.
Related
I'm debugging an app in a real device and Eclipse. Certain feature makes it crash. There is no error on LogCat. I've managed to find which line it crashed in a similar situation by writting Log.v in many lines until I found which Log.v didn't show up. Isn't there a better solution?
You could use the Debugging feature in Eclipse - it allows you to break the program flow on the occurrence of an exception (Run As -> Debug).
This will allow you to inspect the current local variables / call stack to further diagnose why the exception occurs.
p.s. One other method I use when hunting down an odd crash is to dump the full LogCat via the 'adb' CLI tool, and inspect it in a text editor. Sometimes the LogCat display in Eclipse can go a bit.. weird..especially if you've been connecting / disconnecting your device while developing (without closing Eclipse)
Check Logcat filters (in Eclipse). Happens to me.
I was using the 'debug' option on Eclipse, which made it not show the error. Detaching the debug after the crash, or just running the application from the begin (without the debug options) shows the error. To find the line, filter your LogCat by application, make the app crash and, on the red text that will appear, look for your package name. And the of the error (expection) itself is on the beginning of that text.
I am very new to Android and Eclipse. I find very difficult to fix up the errors in Eclipse. Android emulator keeps crashing, even for few lines of codes. Is there any tutorial or video tutorial available, that can help me to spot errors on looking at the error log.
Here is a basic tutorial that will get you familiar with Android Debugging and Logcat : Debugging in Android using Eclipse . Also you can set breakpoints and debug as you would for any other Eclipse project. The logging of errors, its different tough, using Logcat.
Yes, you can open DDMS perspective and LogCat window to view logs and can see what is the original issue.
When it crashes, check the LogCat. It contains the stack trace with the exception, and is often enough to see what went wrong and fix it. It can be browsed directly in Eclipse (don't know exactly how, I'm using IntelliJ).
Also, you can use normal debugging on your Android project, exactly the same way you would on a Java (non-Android) project.
I have just started doing Android development on Mac OS X in Eclipse. When debugging an Activity, I keep getting the following errors:
The JAR file /platforms/android-10/android.jar has no source attachment.
This is starting to get very annoying, does it mean something is throwing an exception somewhere? (the message itself does not give any meaningful information as to why this is happening) I do not want to step into the source; does Eclipse do this by default? How do I disable it?
It looks like you have some error in your application. And Android subsystem throws exception. Normally, if such exception originates from android, you'll see this behavior.
What you should do:
Turn on LogCat view to see logs.
Launch your app without debugger (Ctrl+F11 on ubuntu/windows)
Inspect those logs in LogCat very carefully. They will contain the place where exception happened (originating from your code). You will then easily be able to fix the issue yourself (or ask for more assistance if needed).
In a normal development workflow you shouldn't hit cases like yours too often. Its just the learning curve :) So stay calm and keep learning.
I'm working on my first Android app and to be honest I'm not sure about most of what I'm doing. Right now I'm stuck on a NullPointerException that is created by a line that refers to another class that, in turn, refers to another class.
How can I locate the error?
The word you are looking for is debug. If you are using eclipse, it's very easy to debug your program in most cases. Two main options in eclipse are to use the logger for debug prints to logcat, or debug the program step by step to detect relevant errors. Here is a tutorial for both options and here is a nice video tutorial in YouTube regarding debug in eclipse.
You can use the Eclipse debugger to help with that. Set a break point above the line that errors out and deploy your app using the Eclipse debugger (with the little bug icon) rather than the standard deployer (the play button). You'll be able to see what is going on right before the line with the error occurs and hopefully fix things up.
If that doesn't work, you can post the stack trace and your method that has the error and we can take a look at it.
I am new to android application development, I am finding it difficult to debug my program I am always getting some abstract message like "your application stopped working" I need to know exactly. I have read there are many ways to debug. What I need to know is the way which will be easy for beginners like me.
If you are using eclipse (if not you should, is the easiest way to develop/debug for android) take a look at these tutorials, specially the second one (there is a lot more out there if you google a little):
http://www.latenightpc.com/blog/archives/2007/11/21/starting-a-debug-session-for-android-with-adt
the main point you should research about is LogCat and debugger (both covered in the above links)
In eclipse always look at the logCat output in the DDMS or Debug window when the app crashes. Often (buried in the output) is a line telling you exactly what statement (file and line number) caused the crash. Sometimes you need to hit resume (F8) in the Debug window to get the output. Once you get that info you could set a breakpoint at the offending statement and then look at what variable(s) are messed up.