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"/>