android.app.Application cannot be instantiated due to NullPointerException

Solution 1:

I had exactly the same error, although with other and more simpler code than yours. I found out that the problem occurred only if I didn't close the app in the emulator after re-run it from eclipse. So if I close it before run it from eclipse, everything works fine. But since I am really new to android, I have no clue why this is so. I previous test apps this was never a problem.

Solution 2:

I did some more tests and lockon the problem in the anonymous inner class for Back button, since the error will appear whenever I clicked this before restarting the app. If I switch activities using the "go back" button on the phone, everything is fine.

I added one line in the inner class

EditEntry.this.finish();

It does solve the problem. I tried to test it more systematical this time. Let's say the code without the above line is A, and the code with this line is B. Scenario goes like follow

1.run A then A --> Error

2.run A then B --> Error

3.run B then A --> OK

4.run B then B --> OK

Therefore, I assume it is some kind of problem about the activity stack?