Testing my Java/Android app - is my setup wrong? - java

I just tried to test my first android app using the emulator, it crashed (as expected). So I load the debug view in Eclipse and now I'm not really sure what I'm looking for...
I see a tab that within the first thread I see a bunch of executions (i guess that's the right word) and they say: Source not found. and has a button that reads Edit Source Lookup Path...
Is there something wrong with my setup here?

No, there's nothing wrong with your setup. My advice is:
As you are still learning Android, use the logcat to catch know what causes your app to crash, instead of using the debugger.
Study how the eclipse debugger works and how to use it (you can learn that writting Java apps, no need of using android)

Related

JUnit Stopping at Breakpoints in Files I Didn't Write and Don't Have Permission to

I am running unit tests on java code using intelliJ and junit. The unit tests were working fine, and they still are . . . until I run in debug mode. Today, when I run in debug mode, all of a sudden, they start iterating through java files that are installed with java, I didn't write, and that I don't have permission for like the following:
This is part of the java code base that I don't have any control over and I didn't set any breakpoint here. Yet it pauses here and makes me click through it to get past it. I wouldn't care if this was only a couple of additional clicks to click through, but I have clicked like 50 times and it still keeps going through base java code that I have no control over and is not what is throwing any problem or issue.
I tried changing the settings for code coverage but that didn't seem to do anything. Is there any way to get junit to only stop at breakpoints that I, myself, specified? Any help here would be appreciated. I didn't see a similar question on Stack Overflow and the stuff on other sites is all about crafting the unit test itself.
So crazy coder (see above) was correct, but I thought I would add (after painfully trying every other alternative) that you have to go to: Run | View Breakpoints and then scroll all the way down on the left side panel (which you may not notice if you have tons of breakpoints like I did) and at the bottom there are breakpoints for Java exceptions. You need to click those OFF see below:

How to use eclipse to explore code that i dont know anything about

I work on large enterprise java monolith code. I am new to the team and recently worked on a task, where my tech lead gave a quick guidance - "When you click this button on UI .... eventually this line of code will be executed. This is where you should start exploring"
Now that I have a specific point/line in code, i can put breakpoint and explore the whole flow after that using step-over/step-in. But if i need to know what happened BEFORE that line of code, how do i do it in eclipse?
Between Clicking that button on UI, and that line of code that my tech lead pointed me to, i need to know what all classes/methods were called. Is there a way to explore it in eclipse?
I apologize for a very basic question. Barely learning java and barely getting familiar with eclipse (just learned debugger and breakpoints yesterday).

How to solve debug issue

Everything was working just fine, but then when I tried to debug again my app. It didn't work and instead, I got the message,
"alternative source available for the class java.lang.class android studio"
I didn't know what it meant. I clicked on disable, now I can't debug anymore and it says the library Dalvik.annotation.optimization.FastNative is not found (java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available)
Does somebody know how to fix this issue? I can run the app, but as you know.. debugging is very useful, especially for someone like me. That has been working with android for just one month ago
I'm using Android Studio 3.6
This is the screen I get when I try to debug
Issues of that sort usually get fixed when you make a clean build then try again, if not try invalidating caches and restarting (File > Invalidate caches/restart)
At the end, the solution was to disable the breakpoints. Especifically the Java Exception breakpoints and Excepction breakpoints, also deleted all my breakpoints just in case. And I can debug again!
To delete breakpoints just go to Run>>View Breakpointsand and uncheck
I hope this helps other newbies like me

AppEngine installation problems

I've been wanting to try using AppEngine in conjuction with my android app. My main problem is i can't seem to get the installation to work corrently, or at least that's what i'm assuming is going wrong.
I installed appengine and all the required plugins with eclipse from the instructions here http://code.google.com/eclipse/docs/appeng_android_install_setup.html But even when i just try run the test project it crashes without error (or at least nothing shows on LogCat or console) when i try and get it to send a message to the webserver and crashes about a minute after just adding a google account on the emulator. Is there any way to fix this that anyone knows of? Or perhaps another tutorial to install, it's getting to the point i'm not really sure where to go from here.

How do you debug a Rails application?

Is it possible to debug a Rails application in a similar way to a Java application - setting breakpoints and stepping into the code?
What are the best tools for this?
I have a hybrid Java/Ruby on Rails application which I can run in Eclipse or Netbeans.
I would like to step into some code in this app and try to figure out the cause of a problem I'm having.
In Eclipse if I set a breakpoint in my blog_controller and then choose the 'Debug' button, it seems to use the ruby-debug-ide gem to execute the code but I get this unhelpful output and no option to step into any source:
Fast Debugger (ruby-debug-ide 0.4.5) listens on localhost:56726
./war/WEB-INF/app/controllers/blog_controller.rb:1
C:/Ruby18/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.5/lib/ruby-debug.rb:101:in `debug_load'
C:/Ruby18/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.5/lib/ruby-debug.rb:101:in `debug_program'
C:/Ruby18/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.5/bin/rdebug-ide:82
C:/Ruby18/bin/rdebug-ide:19:in `load'
C:/Ruby18/bin/rdebug-ide:19
Uncaught exception: uninitialized constant ApplicationController
I'm not sure if I'm doing something wrong or if this is all I can expect.
The debugger I use the most is the ruby-debug gem, which is a gdb-esque command line debugger. Once you learn a few commands it is very quick and effective, and provides you with some handy features like being able to fire up irb in the context of your program and make on-the-fly changes.
And being command line based it comes in handy when you need to debug a on a remote server.
You can expect more. I have used Aptana's RadRails version of Eclipse to debug a Rails app as you describe--setting breakpoints and stepping through the code.
You may be doing something wrong. It looks as if it is trying to debug an individual controller file, rather than debugging the Rails app. When I try to execute a controller file from the command line, I get a similar message:
C:\workspace\myapp\app\controllers>ruby users_controller.rb
users_controller.rb:1: uninitialized constant ApplicationController (NameError)
In Aptana RadRails, I choose Run > Debug As > Ruby Application to debug the app.
For the vim users I strongly recomend looking into the vim-ruby-debugger, which fits in great with Tim Pope's rails.vim scripts.
It gives you a handy :Rdebugger command, allows you to set breakpoints and open a split window to display variable values.
maybe not relevant, but I wanted to post somewhere: got the error: "undefined method `run_init_script' for Debugger:Module" running the debugger in rails 2.3.2. Did a sudo gem install ruby-debug and the problem went away.
I'd recommend just setting up breakpoints (I actually just puts to console) for 99% of debugging with RoR - this method is simple and usable across any IDE, so you never need to learn how a new debugger works.
Actually, I had the same problem with Aptana. Run > Debug As > Ruby Application just doesn't work. I finally made the debugger work by going to the Servers tab, and then start the server in debug mode. After that, set some breakpoints and trigger the corresponding action. Hope this helps.
Debugging? That's just knowing where to look in the case of Ruby (and by extension, Rails) most of the time.
The problem in this case is that you probably still have your ApplicationController called application.rb where it should be renamed to application_controller.rb.
Debuggin in rails is simple if you know how to read the error stacktrace!! But if you need to explicitly watch out the values during the runtime then u can use the rails breakpointer.Below is the link to how-to on breakpointer ..hope this helps!!!
http://destiney.com/blog/rails-breakpointer
I can't speak for Eclipse (never worked well for me) or Aptana (not tried) but from experience I can say that both NetBeans and RubyMine will do what you want. I both cases you should probably make sure that the ruby-debug-base and ruby-debug-ide gems are up-to-date: RubyMine in particular didn't work for me until that was done.

Categories