• Register
0 votes

Problem :

I was trying to run a sample code While launching the application in the android 1.5 emulator , I got bellow errors.... Any one have any hint ?
java.lang.runtimeexception: unable to instantiate activity componentinfo
6 5 3
6,930 points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :


I unchecked the jars that needed be exported to the apk and this same thing happened. Please tick the jars that your app Needs to run.And your issue will be resolved.

Further Readings:


9 7 4
38,600 points
0 votes


Please include your Activity in your AndroidManifest.xml.

At the time you want to create a new activity, you must register it in your AndroidManifest.xml.

You may be attempting to find the view before onCreate() which is incorrect.

public class MainActivity extends Activity {

  ImageView mainImage = (ImageView) findViewById(R.id.imageViewMain); //incorrect

  protected void onCreate(Bundle savedInstanceState){

There is another method to obtain an java.lang.RuntimeException: Unable to instantiate activity Component Info exception and that is the activity that you are attempting to begin is abstract. I made this stupid mistake at one time and its very simple to overlook.

In my instance I forgot to include the google maps library


    <uses-library android:name="com.google.android.maps" />

Further, check that you're not missing the former dot prior the activity path

<activity android:name=".activities.MainActivity"/>

This error can also be the ultimate sign of a dumb mistake (like when I - I imply, cough, like at the time a friend of mine who showed me their code once) where they attempt to execute code outside of a method like attempting to do this:

SQLiteDatabase db = openOrCreateDatabase("DB", MODE_PRIVATE, null); //trying to perform function where you can only set up objects, primitives, etc

public void onCreate(Bundle savedInstanceState) {

Rather than this:

SQLiteDatabase db;

public void onCreate(Bundle savedInstanceState) {
db = openOrCreateDatabase("DB", MODE_PRIVATE, null);

For me, my package string in AndroidManifest.xml was inaccurate . Ensure that the package string in this file is the similar as where your main activity is, for example


A simple method to do this is to open the AndroidManifest.xml file in the "Manifest" tab, and type it in the text box next to Package, or usage the Browse button.

Further, the package string for my activity was wrong, for example

<activity android:name="com.example.app.MainActivity" android:label="@string/app_name">

In case this is the instance, you require to include an extra configuration in the webpack.config.js file. To resolve the incident include `MainActivity: ./activity', to the entry in webpack.config.js like this:

const entry = {
    // Discover entry module from package.json
    bundle: `./${nsWebpack.getEntryModule()}`,
    // Vendor entry with third-party libraries
    vendor: `./vendor`,
    /// HERE
    MainActivity: './activity',
    // Entry for stylesheet with global application styles
    [mainSheet]: `./${mainSheet}`,

Remember that after you make those changes, you must remove node_modules and platforms folder before rebuilding the app.

10 6 4
31,120 points

Related questions

0 votes
1 answer 72 views
Problem : I am getting bellow error while trying to run my android code. java.lang.runtimeexception: unable to start activity componentinfo
asked Nov 2, 2019 peterlaw 6.9k points
0 votes
1 answer 34 views
I got these errors.... Any one have some hint..?
asked Dec 7, 2020 TeamScript 13.5k points
0 votes
1 answer 269 views
Cannot create controller in thread that did not call Looper.prepare () What does the following exception mean? How can I fix it? Here is the code: Toast toast = Toast.makeText (mContext, "Something", Toast.LENGTH_SHORT); This is the exception: Java.lang.RuntimeException: Cannot ... :121)      on Android.widget.Toast. <init> (Toast.Java:68)      on Android.widget.Toast.makeText (Toast.Java:231)
asked Aug 17, 2020 game 4.6k points
0 votes
1 answer 538 views
Problem : I am getting bellow in Android Studio java.lang.runtimeexception: an error occurred while executing doinbackground()
asked Oct 19, 2019 peterlaw 6.9k points
0 votes
1 answer 78 views
Problem : While executing Android code getting below error java.lang.illegalstateexception could not execute method of the activity
asked Oct 23, 2019 peterlaw 6.9k points
0 votes
1 answer 8 views
0 votes
1 answer 90 views
Problem : I am getting bellow error while running my program and unable to figure out what the solution would be a fatal error has been detected by the java runtime environment:
asked Nov 5, 2019 peterlaw 6.9k points
2 votes
1 answer 50 views
Problem: I started learning C++ programming recently and trying to write my very first program in C++. Here is my sample code #include <iostream> #include <Stdio.h> using namespace std; int main(){ cout << "I am a C++ program" << endl; return 0; } As ... last thirty minutes and failed to gather the information about it. Could you, please save my day? I must recognize your kind help. Thanks, guys.
asked Apr 16, 2020 Gavin 15.3k points
0 votes
1 answer 3 views
Problem : Failed to instantiate one or more classes android studio
asked 4 days ago Shovo210 3.1k points