Simulator prompt Unfortunately, Activity has stopped.
Just beginning to learn Android development, facing a simple example of a book to write again, the results of running to use the simulator, always prompt Unfortunately, Activity has stopped., Less code, I hope to know to be able to help solve what, grateful . First code MyView.java
These two java files, because there is no design to layout files, they do not stick layout file it, the project name is the Activity, simulator time is always running to prompt Unfortunately, Activity has stopped. Reply: The above information LogCat stickers out
Sorry, something these days, I'll just stick. Reply:
Thank you give pointers, plus where to ask, is added to the file you AndroidManifest.xml Reply: AndroidManifest.xml is configured to increase activity Reply:
lz is not no statement ActivityDemo manifest file in AndroidManifest.xml Carefully check the operation flow on the lower book mentioned Reply: The amount, the above methods are tried, or why not. I posted about logcat inside to error, paste what AndroidManifest.xml file, you help to see. This is the wrong message.
03-25 13: 15: 26.109: E / Trace (937): error opening trace file: No such file or directory (2) 03-25 13: 15: 26.339: D / AndroidRuntime (937): Shutting down VM 03-25 13: 15: 26.399: W / dalvikvm (937): threadid = 1: thread exiting with uncaught exception (group = 0x40a71930) 03-25 13: 15: 26.459: E / AndroidRuntime (937): FATAL EXCEPTION: main 03-25 13: 15: 26.459: E / AndroidRuntime (937): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo {picksomething.activity / picksomething.activity.ActivityDemo}: java.lang.NullPointerException 03-25 13: 15: 26.459: E / AndroidRuntime (937): at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2106) 03-25 13: 15: 26.459: E / AndroidRuntime (937): at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2230) 03-25 13: 15: 26.459: E / AndroidRuntime (937): at android.app.ActivityThread.access $ 600 (ActivityThread.java:141) 03-25 13: 15: 26.459: E / AndroidRuntime (937): at android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1234) 03-25 13: 15: 26.459: E / AndroidRuntime (937): at android.os.Handler.dispatchMessage (Handler.java:99) 03-25 13: 15: 26.459: E / AndroidRuntime (937): at android.os.Looper.loop (Looper.java:137) 03-25 13: 15: 26.459: E / AndroidRuntime (937): at android.app.ActivityThread.main (ActivityThread.java:5041) 03-25 13: 15: 26.459: E / AndroidRuntime (937): at java.lang.reflect.Method.invokeNative (Native Method) 03-25 13: 15: 26.459: E / AndroidRuntime (937): at java.lang.reflect.Method.invoke (Method.java:511) 03-25 13: 15: 26.459: E / AndroidRuntime (937): at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:793) 03-25 13: 15: 26.459: E / AndroidRuntime (937): at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:560) 03-25 13: 15: 26.459: E / AndroidRuntime (937): at dalvik.system.NativeStart.main (Native Method) 03-25 13: 15: 26.459: E / AndroidRuntime (937): Caused by: java.lang.NullPointerException 03-25 13: 15: 26.459: E / AndroidRuntime (937): at android.content.ContextWrapper.getResources (ContextWrapper.java:89) 03-25 13: 15: 26.459: E / AndroidRuntime (937): at android.view.ContextThemeWrapper.getResources (ContextThemeWrapper.java:78) 03-25 13: 15: 26.459: E / AndroidRuntime (937): at android.view.View & lt; init & gt; (View.java:3226) .03-25 13: 15: 26.459: E / AndroidRuntime (937): at picksomething.activity.MyView & lt; init & gt; (MyView.java:11) .03-25 13: 15: 26.459: E / AndroidRuntime (937): at picksomething.activity.ActivityDemo & lt; init & gt; (ActivityDemo.java:9) .03-25 13: 15: 26.459: E / AndroidRuntime (937): at java.lang.Class.newInstanceImpl (Native Method) 03-25 13: 15: 26.459: E / AndroidRuntime (937): at java.lang.Class.newInstance (Class.java:1319) 03-25 13: 15: 26.459: E / AndroidRuntime (937): at android.app.Instrumentation.newActivity (Instrumentation.java:1054) 03-25 13: 15: 26.459: E / AndroidRuntime (937): at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2097) 03-25 13: 15: 26.459: E / AndroidRuntime (937): ... 11 more 03-25 13: 15: 30.619: I / Process (937): Sending signal PID:. 937 SIG: 9
Override protected void onCreate (Bundle savedInstanceState) { super.onCreate (savedInstanceState); MyView myView = new MyView (this); this.setContentView (myView); } Ok, now I do not know why, I just started to learn android! Reply: Analysis of what know the source due to the: onCreate () function before the constructor call activity objects have run, and this time the object has not been created, so myView point to null, is not referenced, so references to him before initialization, also It is again this.setContentView (myView); before! Reply:
Thank you! ! ! I thought for a long time or did not result, the last against your approach to solve the Reply: I am also a beginner, experienced similar problems. Tinkering in AndroidManifest.xml file Reply: Reply:
What is the specific solution is? I am also a beginner Reply: I also encountered a say in AndroidMenifest.xml, but do not know how to change Reply: Permissions SEND_SMS Reply: Reply: pro, I declare again show how still ah Reply:
Analysis of what know the source due to the: onCreate () function before the constructor call activity objects have run, and this time the object has not been created, so myView point to null, is not referenced, so references to him before initialization, also It is again this.setContentView (myView); before!
Thank you! ! ! I thought for a long time or did not result, the last against your approach to solve the
pro, I declare again show how still ah
I am a novice, also encountered, it has been resolved, to those who need reference Paint paint = new Paint (); Thank http://www.th7.cn/Program/Android/201407/246852.shtml
No comments:
Post a Comment