The android program's unable to instantiate activity componentinfo is abnormal.

Source: Internet
Author: User

Article transferred from: http://www.j2men.com/index.php/archives/454

Today, I have been writing programs by Java. lang. runtimeexception, we all think of these possibilities:

It is a problem of your intent.

Please add your activity in your androidmanifest. xml.

When you want to making new activity, you shoshould register it in your androidmanifest. xml.

This indicates that the activity class has been written and you want to pass it through intent to switch the activity. However, this activity is not added to the manifest. xml file, so you cannot instantiate the activity.

In my case I forgot to add the Google Maps Library

Uses-library Android: Name = "com. Google. Android. Maps"

It may be useful to someone: http://developer.android.com/resources/tutorials/views/hello-mapview.html

Also, check that you're not missing the preceding dot before the activity path

<Activity Android: Name = ". Activities. mainactivity"/>

This indicates that the class path is not written correctly (for example, an activyty is in the com. in the j2men package, one is in COM. j2men. in the UI package, the default package defined in manifest is com. j2men. if you write a new activity. before the class name, Add. UI) or in manifest. android: Name = ". class Name.

There is another way to get an Java. lang. runtimeexception: Unable to instantiate activity componentinfo exception and that is the activity that you are trying to start is abstract. I made this stupid mistake once and its very easy
To overlook.

This person means that if you define the default intent activity as an abstract class, this error will also pop up.

If you have considered these three cases and made the corresponding changes, you will still throw this exception. Another trick is: check whether the constructor and oncreate () methods exist in the activity class you want to open. If yes, delete the constructor. Put initialization in the oncreate () method.

If a networked program cannot obtain data, check whether the manifest. xml file has forgotten the statement for adding network permissions:

<Uses-Permission Android: Name = "android. Permission. Internet"/>

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.