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.
Related
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.
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 relatively new to using Eclipse with the Android SDK. Whenever I encounter an error/force close, Eclipse displays a page showing "Source not found"
Is it possible to get it to show the error that is causing this? I assume this is achieved by somehow linking to the android source code. Is this mistaken?
Basically, I am struggling to identify the source of my error, and am hoping eclipse can offer more information than at present.
Appreciate any help with this,
Venatu
Source not found because the Exception is raised from something that you don't have source code, (e.g. Android SDK). You should always refer to the LogCat (Window -> Show View -> Other -> Android -> LogCat) to get the extended information about your exceptions.
Reference: http://developer.android.com/guide/developing/debugging/debugging-projects.html
Yes, most likely eclipse tries to access the android code, which isnt possible since its a library. If you get a force close or any other crash it's always a good idea to take a look inside the logcat, Android prints the stacktrace there. You can usually see exactly which function and codeline causes the issue.
Open the logcat either inside Eclipse via Window->Show View->Other->Log cat
or by starting the ddms application inside the android-sdk/tools directory.
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.
This is a really stupid question I imagine, but is there a way to search for hidden errors. I'm working on a project in MotoDev's Eclipse environment, and it won't let me run suddenly stating that I need to fix errors first, but it won't show any errors in the log at all.
Check out the Problem view, you may get something there.
There shouldn't be any hidden errors in MOTODEV Studio. As Tony mentions, bring up the Problem view to see if there are any errors listed there. Also, look in the project explorer and see if there are any files or folders with a red X on them, which indicates a file with a problem is in there. Failing that, do a clean build on the project.
If the problems persist, give us a shout on the MOTODEV forums and we'll work with you to get the issue resolved.
Eric