Android getting started error solution (1): Fatal exception: Main

Source: Internet
Author: User

When I first started to work on Android, I had to encounter some simple problems for the experts, but I was a newbie, here we will save some technical notes that I am engaged in Android development and hope they will be helpful to future users.

This article is original. Do not use it for commercial purposes. If you need to reprint the record, please keep the copyright information and notify me to request the right to reprint the record.

1. the following error message is displayed in the logcat window:

01-30 12:13:15. 829: I/system. Out (3043): Waiting For debugger to settle...
01-30 12:13:16. 039: I/system. Out (3043): debugger has settled (1342)
01-30 12:13:21. 570: D/androidruntime (3043): Shutting Down VM
01-30 12:13:21. 570: W/dalvikvm (3043): threadid = 1: thread exiting with uncaught exception (group = 0x40018578)
01-30 12:13:21. 640: E/androidruntime (3043): Fatal exception: Main
01-30 12:13:21. 640: E/androidruntime (3043): Java. Lang. runtimeexception: unable to start activity componentinfo {program java. Lang. nullpointerexception
01-30 12:13:21. 640: E/androidruntime (3043): at Android. App. activitythread. initialize mlaunchactivity (activitythread. Java: 1651)
01-30 12:13:21. 640: E/androidruntime (3043): at Android. App. activitythread. handlelaunchactivity (activitythread. Java: 1667)
01-30 12:13:21. 640: E/androidruntime (3043): at Android. App. activitythread. Access $1500 (activitythread. Java: 117)
01-30 12:13:21. 640: E/androidruntime (3043): at Android. App. activitythread $ H. handlemessage (activitythread. Java: 935)
01-30 12:13:21. 640: E/androidruntime (3043): at Android. OS. handler. dispatchmessage (handler. Java: 99)
01-30 12:13:21. 640: E/androidruntime (3043): at Android. OS. Looper. Loop (Looper. Java: 130)
01-30 12:13:21. 640: E/androidruntime (3043): at Android. App. activitythread. Main (activitythread. Java: 3687)
01-30 12:13:21. 640: E/androidruntime (3043): At java. Lang. Reflect. method. invokenative (native method)
01-30 12:13:21. 640: E/androidruntime (3043): At java. Lang. Reflect. method. Invoke (method. Java: 507)
01-30 12:13:21. 640: E/androidruntime (3043): At com. Android. Internal. OS. zygoteinit $ methodandargscaller. Run (zygoteinit. Java: 867)
01-30 12:13:21. 640: E/androidruntime (3043): At com. Android. Internal. OS. zygoteinit. Main (zygoteinit. Java: 625)
01-30 12:13:21. 640: E/androidruntime (3043 ):
At Dalvik. system. nativestart. Main (native method)
01-30 12:13:21. 640: E/androidruntime (3043): caused by: Java. Lang. nullpointerexception
01-30 12:13:21. 640: E/androidruntime (3043): At loger.gps.any2go.com. gpsactivity. oncreate (gpsactivity. Java: 31)
01-30 12:13:21. 640: E/androidruntime (3043): at Android. App. instrumentation. callactivityoncreate (instrumentation. Java: 1047)
01-30 12:13:21. 640: E/androidruntime (3043): at Android. App. activitythread. initialize mlaunchactivity (activitythread. Java: 1615)
01-30 12:13:21. 640: E/androidruntime (3043):... 11 more

From the above information, we can see that logcat has helped us locate the specific problem, as shown in the cold color of the first line, the same occurs in the main function, and the exception is nullpointerexception, the specific line occurs in the green background, in the oncreate function. Gpsactive. Java: 31 rows.

In this way, we found the problem in detail. This problem confused me for an afternoon, and now I have to look at it again. In just a few minutes, I found it and published it here to encourage everyone.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.