I am developing an android app on netbeans. If, for example, I were to add System.out.println("Hello World") attached to a button click, it does not output anywhere. Am I missing something basic?
This also means I can never see if exceptions are being thrown or anything. If my app works it works and if not I am developing 'blind'. Help?
On Android all of those go to the on device logcat. Not sure how you'd see that with netbeans, but you'd need to hook it up to adb logcat in some fashion.
Related
I am working on an app,which I have installed in my Smartphone, I wanted to check the flow of code while running the app.
using Android Studio I installed the app via USB Debugger, and open the app project files in
chrome://inspect/#devices
, while running , I have added multiple breakpoints in the code to see the flow, but the code haven't stopped at any breakpoint, yet there is no issue with the running of app, the app ran smoothly.
I am facing the same issue while using emulator as well.
Can someone help me to figure out, what I could do ?
EDIT -
I have followed #KannanSJD instructions as well, by "Attaching Debugger to Android" and selecting "Java Only" but not got any success. , As you can see in the below attachments
make sure you attach your debugger to your app process. Use the below icon on top left
if your app package and its process is not showing then make sure you are running in Debug mode and not in release mode using build variants.
Make sure your app is open and you see your process as in screenshot.
Also instead of detect automatically you cna use Java only if you have NDK also used in your project. This will fasten the process of attaching debugger.
Also make sure you find the following log in your debug console.
Please check if you have muted your breakpoints, refer following image. That should NOT be enabled.
I would really appreciate if someone can help me with my problem:
I am using Android Studio. I want to create the simplest of apps: Just a "Hello World" would be ok.
So I start by creating a new app with an Empty Activity (so far I was using a "Blank Activity" but as you know, they are different.
So I create the basic code (and I find several problems -for example "cant resolve symbol AppCompatActivity- but I dont know how, it got solved...and then I have other problems..etc but...)
So, I finally get a "hello world" app, with everything ready to run. All errors corrected "by magic"- I mean really... anyway I push the Run button.(i am using genimotion by the way cause the native emulator is another problem!) and it starts to run
and I wait.... and wait.... and wait....
it never runs. I can see "gradle processes running"
So I *stop * (by clicking Run-> Stop)
the gradle processes seem to stop
and then the app finally runs succesfully and load into the genimotion emulator and I can run without problems...
So my question is: What is happening here? Why do I have to stop in order to run??
Thanks a lot for any useful help you can give me
if its possible to see what type of run time exception in android mobile? because i developed one application which works fine in emulator but stop working in mobile.. is there any Log-cat..
[a Log-cat]: https://play.google.com/store/apps/details?id=org.jtb.alogcat&hl=en doesn't shows errors..! i cant find any tutorials for "a Log-cat" apk.. please help me!! Thanks in adavance
You will find a lot of applications to read the Log of your installed Apps, but they require root permissions to display the exceptions.
If you have the sdk tools installed you have access to the log cat from that if you run your apk while connected to the computer. If you use eclipse there is even a guy with easy access to it, otherwise there are command line tools.
In essence, plug it into your computer and you can get to the logs.
I would recommend you work through:
https://developer.android.com/training/basics/firstapp/index.html?hl=cn
As it will get you set up and teach you to use the tools. If you don't want to do that:
Command Line:
http://developer.android.com/tools/help/logcat.html
Eclipse:
How to enable LogCat/Console in Eclipse for Android?
How to debug on a real device (using Eclipse/ADT)
IntelliJ
https://www.jetbrains.com/idea/webhelp/debugging-with-logcat.html
Short: Either root and use an application to view the log cat, or plug it into your computer.
you can try this code to view it
try{
//do something
}catch(Exception e){
Toast.makeText(context,e.message(),Toast.LENGTH_LONG).show();
//or you can start a new ACTIVITY and put STACKTRACE in a TextView
}
But this have a drawback that you should know that in which part of you app the Exception may occur.
I have tried it using a Toast. Hope it helps.
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.