Android Development java.lang.RuntimeException:Unable to start activity componentinfo{xxx}

Source: Internet
Author: User

Android Development java.lang.RuntimeException:Unable to start activity componentinfo{xxx}: Java.lang.NullPoi

Error message string: Java.lang.RuntimeException:Unable to start activity Componentinfo{com.first/com.first.game}: Java.lang.NullPointerException

Generally in the activity OnCreate () method of Setcontentview (XXX) This error occurs, online access to a number of reasons, there are about four important possible reasons:

Reason one: XXX error, if it is r.layout.main then should be the Main.xml file label use error, the most common and the compiler will not prompt the error is android:name and Android:id both confused, Carefully check that the Main.xml labels are all correct

Reason two: the Requestwindowfeature () method is used after the Setcontentview (view) method, and under this error, the requestfeature must be used before Setcontentview, Only need to put the Requestwindowfeature () method before the Setcontentview (view) method can be resolved

Reason three: In addition to the OnCreate () method, and does not belong to any one method of the body directly to a control FindByID (r.id.xx) caused, need to be within a method and before the Setcontentview (view) method FindByID ( R.ID.XX) can be resolved

Reason four: The view is not instantiated prior to Setcontentview (view), only declared and directly setcontentview (view), carefully check whether the view Setcontentview (view) can be resolved before calling and instantiating within a method

Cause five: Because of a null pointer error exception, you should check if there is a value in something like Spinner or list.

Android Development java.lang.RuntimeException:Unable to start activity componentinfo{xxx}

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.