Android NotePad Tutorial 1 : Crash when I click on "Menu"

2

I am a beginner with Android, and I have a strange bug with the NotePad Tutorial (Exercice 1). http://developer.android.com/resources/tutorials/notepad/index.html

I imported the sources and completed the code, but when I run the app, and click on the "Menu" button, it crashes (The application .... has stopped unexpectedly. Please try again.)

Then, I imported the solution, and it works normally.

I copied the whole code, resources, manifest from the solution to the first Project ... and still, everything is good with the first project, but when I click "Menu", I have the same crash.

Can someone explain where am I making a mistake?

After some researches, I opened the LogCat. Here are the lines that seems interesting :

Displayed activity com.android.demo.notepad1/.Notepadv1: 1261 ms (total 1261 ms)
No keyboard for id 0

Using default keymap: /system/usr/keychars/qwerty.kcm.bin

getEntry failing because entryIndex 2 is beyond type entryCount 2

Failure getting entry for 0x7f040002 (t=3 e=2) in package 0: 0x80000001

Shutting down VM

threadid=3: thread exiting with uncaught exception (group=0x4001b188)

Uncaught handler: thread main exiting due to uncaught exception

android.content.res.Resources$NotFoundException: String resource ID #0x7f040002

I noted that 0x7f040002 refers to the "menu_insert" string in R.java

android
asked on Stack Overflow Jul 25, 2011 by Mar Cnu • edited Jul 25, 2011 by hari

3 Answers

1

My only guess is that R.java is not refreshed properly. Did you try a project>clean in Eclipse? That will recreate the R.java file.

answered on Stack Overflow Jul 25, 2011 by Exegesis
0

I didn't like the answer you linked to either. After some research I added these two lines to my code. The editText name is from my own program:

         txtUserWord.setFocusableInTouchMode(true);
         txtUserWord.setFocusable(true);

The error message in the logcat doesn't appear anymore.

answered on Stack Overflow Jul 25, 2011 by John Feagans
0

My issue for this (well actually the crash occurred after I pressed "Add Item") was a misspelling of the xmlns attribute.

answered on Stack Overflow Aug 30, 2011 by joshv2

User contributions licensed under CC BY-SA 3.0