java.lang.RuntimeException: Unable to instantiate activity ComponentInfo

前端 未结 30 2229
感动是毒
感动是毒 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:42

    I had the same problem, but I had my activity declared in the Manifest file, with the correct name.

    My problem was that I didn't have to imported a third party libraries in a "libs" folder, and I needed reference them in my proyect (Right-click, properties, Java Build Path, Libraries, Add Jar...).

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

    This error also occurs when you use of ActionBarActivity but assigned a non AppCompat style.

    To fix this just set your apps style parent to an Theme.AppCompat one like this.:

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light">
        <!-- Customize your theme here. -->
    </style>
    
    0 讨论(0)
  • 2020-11-22 15:44

    In my case, I was trying to embed the Facebook SDK and I was having the wrong Application ID; thus the error was popping up. In your manifest file, you should have the proper meta data:

    <meta-data
    android:name="com.facebook.sdk.ApplicationId"
    android:value="@string/facebook_app_id" />
    
    0 讨论(0)
  • In my case, I was trying to initialize the components(UI) even before the onCreate is called for the Activity.

    Make sure your UI components are initialized/linked in the onCreate method after setContentView

    NB: This is my first mistake while learning Android programming.

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

    This happened to me when I tried to run an Activity on 2.2 that used imports from Honeycomb not available in older versions of Android and not included in the v4 support package either.

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

    In my case I haven't set the setContentView(R.layout.main);

    If you create a new class do not foget to set this in on onCreate(Bundle savedInstanceState) method.

    I have done this stupid mistake several times.

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