I am testing the example given on http://developer.android.com/resources/t开发者_Go百科utorials/notepad/notepad-ex1.html.
I have followed the steps as mentioned in the tutorial. The application is successfully launched in the emulator
But when i click on the menu button error comes
When i check in eclipse console it does not show any error.
When i open DDMS perspective in eclipse and go to the File Explorer. Inside File Explorer when i go to the data/data/com.android.demo.notepad1/. I see two folders one showing 5120 size.
Under Log Cat following error is coming:
04-05 16:19:07.267: ERROR/AndroidRuntime(345): FATAL EXCEPTION: main
04-05 16:19:07.267: ERROR/AndroidRuntime(345): android.content.res.Resources$NotFoundException: String resource ID #0x7f040002
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at android.content.res.Resources.getText(Resources.java:201)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at android.content.res.Resources.getString(Resources.java:254)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at com.android.internal.view.menu.MenuBuilder.add(MenuBuilder.java:397)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at com.android.demo.notepad1.Notepadv1.onCreateOptionsMenu(Notepadv1.java:45)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at android.app.Activity.onCreatePanelMenu(Activity.java:2158)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:323)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel(PhoneWindow.java:568)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at com.android.internal.policy.impl.PhoneWindow.onKeyDown(PhoneWindow.java:1210)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1668)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2560)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2535)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at android.view.ViewRoot.handleMessage(ViewRoot.java:1867)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at android.os.Handler.dispatchMessage(Handler.java:99)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at android.os.Looper.loop(Looper.java:123)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at java.lang.reflect.Method.invoke(Method.java:507)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-05 16:19:07.267: ERROR/AndroidRuntime(345): at dalvik.system.NativeStart.main(Native Method)
04-05 16:19:07.366: WARN/ActivityManager(67): Force finishing activity com.android.demo.notepad1/.Notepadv1
04-05 16:19:07.926: WARN/ActivityManager(67): Activity pause timeout for HistoryRecord{405525f0 com.android.demo.notepad1/.Notepadv1}
04-05 16:19:19.540: WARN/ActivityManager(67): Activity destroy timeout for HistoryRecord{405525f0 com.android.demo.notepad1/.Notepadv1}
04-05 16:20:39.455: DEBUG/SntpClient(67): request time failed: java.net.SocketException: Address family not supported by protocol
04-05 16:24:11.534: INFO/Process(345): Sending signal. PID: 345 SIG: 9
04-05 16:24:12.428: ERROR/InputDispatcher(67): channel '406a5ed8 com.android.demo.notepad1/com.android.demo.notepad1.Notepadv1 (server)' ~ Consumer closed input channel or an error occurred. events=0x8
04-05 16:24:12.468: ERROR/InputDispatcher(67): channel '406a5ed8 com.android.demo.notepad1/com.android.demo.notepad1.Notepadv1 (server)' ~ Channel is unrecoverably broken and will be disposed!
04-05 16:24:12.572: INFO/ActivityManager(67): Process com.android.demo.notepad1 (pid 345) has died.
04-05 16:24:12.719: INFO/WindowManager(67): WIN DEATH: Window{406a5ed8 com.android.demo.notepad1/com.android.demo.notepad1.Notepadv1 paused=false}
Please help me trace out the reason for such error
Thanks
Pankaj
I have resolved the issue. Actually when i imported the project there was drawable folder along with drawable-hdpi, drawable-mdpi and drawable-ldpi folder.It was causing the conflict. I have removed the drawable folder and put the image which was in it to the hdpi,mdpi & ldpi folders. Now when i run the application, it works as expected.
I was having this problem also. I decided to try deleting the drawable-hdpi, drawable-ldpi, and drawable-mdpi directories. This didn't work. However, when diffing all the files in my solution versus the Notepadv1Solution, I noticed there seems to be a discrepancy in one of the xml files. On the notepad excercise 1 site under step 4, the xml for notepad_list.xml is written as
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ListView android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_notes"/>
</LinearLayout>
However, in the Notepadv1Solution, this same file is written as
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ListView android:id="@id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@id/android:empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_notes"/>
</LinearLayout>
When I replaced the code from the site with the code from the solution, it started working.
精彩评论