I am going through the android hello world tutorial, and have been stuck when trying to create an XML UI. For some reason, even on a new program, in which I have made no changes to the default build, it gives the error java.lang.NullPointerException after every character I type. I can't figure out why it is doing this, as I am just trying to edit the text between the Text I want to set it to say something other than what is set by default. However, even with a fresh build, no changes, and I just try to change the text within the xml tags, it still gives the error. What do I need to do to allow it to let me type? I am using the eclips IDE and the android sdk. I was able to do the first part of the tutorial that doesn't involve XML.
Just guessing, but I suspect you are doing something like the following:
<TextView android:text="@string/hello" />
and you are editing it to
<TextView android:text="@string/helloWorld" />
without creating a reference in res/values/strings.xml
.
If this is the case, go to strings.xml and edit the proper string there, for example
<string name="hello">Hello World!</string>
becomes
<string name="hello">Hello everybody!</string>
Ok, I finally found the answer somewhere else, it was something wrong with how the file was created by default. I have to add the element xmlns:android as follows
<resources xmlns:android="http://schemas.android.com/apk/res/android" />
Interestingly enough, the file will work if I type it one character at a time, dismissing the pop up with each keystroke. However the new element eliminates the pop ups. I am not sure why the error would pop up, yet the program still compile and run correctly on my avd. Oh well, if you have this error add the element and it goes away
Hi Dusty I am suffering from the same problem and it been driving me nuts. I’m new to android development and am a little lost as to where you add this code could you be a little more specific. I did notice the link already in the manifest file any help would be greatly appreciated.
I think in your typing contain UTF-8 not pure ASCII. You can change in eclipse by in Ecipse IDE Window> preference> Under General tab, select workspace. In text file encoding choose other, in these choose UTF-8 . It will be ok