java.lang.RuntimeException: Unable to instantiate activity ComponentInfo

前端 未结 30 2445
感动是毒
感动是毒 2020-11-22 15:15

I was trying to run a sample code While launching the application in the android 1.5 emulator , I got these errors.... Any one have some hint..?

ERROR from LogCat:<

相关标签:
30条回答
  • 2020-11-22 15:52

    I recently encountered this with fresh re-install of Eclipse. Turns out my Compiler compliance level was set to Java 1.7 and project required 1.6.

    In Eclipse: Project -> Properties -> Java Compiler -> JDK Compliance

    0 讨论(0)
  • 2020-11-22 15:52

    Right click on project > properties > android > and try with different version of the android earlier i was doing with android 4.4 then i changed to android 4.3 and it worked !

    0 讨论(0)
  • 2020-11-22 15:53

    I had the same issue (Unable to instantiate Activity) :

    FIRST reason :

    I was accessing

    Camera mCamera;
    Camera.Parameters params = mCamera.getParameters();
    

    before

    mCamera = Camera.open();
    

    So right way of doing is, open the camera first and then access parameters.

    SECOND reason : Declare your activity in the manifest file

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

    THIRD reason : Declare Camera permission in your manifest file.

    <uses-feature android:name="android.hardware.Camera"></uses-feature>
    <uses-permission android:name="android.permission.CAMERA" />
    

    Hope this helps

    0 讨论(0)
  • 2020-11-22 15:54

    Simply Clean your working project or restart eclipse. Then run your project. it will work.

    0 讨论(0)
  • 2020-11-22 15:55

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

    public class MainActivity extends Activity {
    
      ImageView mainImage = (ImageView) findViewById(R.id.imageViewMain); //incorrect
    
      @Override
      protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
      }
      ...
    }
    
    0 讨论(0)
  • 2020-11-22 15:59

    It is a problem of your Intent.

    Please add your Activity in your AndroidManifest.xml.

    When you want to make a new activity, you should register it in your AndroidManifest.xml.

    0 讨论(0)
提交回复
热议问题