java.lang.RuntimeException: Unable to instantiate activity ComponentInfo

前端 未结 30 2444
感动是毒
感动是毒 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 16:03

    For me it was different from any of the above,

    The activity was declared as abstract, That is why giving the error. Once it removed it worked.

    Earlier

         public abstract class SampleActivity extends AppcompatActivity{
         }
    

    After removal

         public class SampleActivity extends AppcompatActivity{
         }
    
    0 讨论(0)
  • 2020-11-22 16:04

    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.

    0 讨论(0)
  • 2020-11-22 16:04

    Another reason of this problem may be a missing library.

    Go to Properties -> Android and check that you add the libraries correctly

    0 讨论(0)
  • 2020-11-22 16:05

    Image

    It also happens because of this issue. 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.

    0 讨论(0)
  • 2020-11-22 16:05

    Your New Activity add AndroidManifest.xml like ".NewActivity"

     </activity>        
        <activity android:name=".NewActivity" />
    
    0 讨论(0)
  • 2020-11-22 16:09

    In my case I forgot to add the google maps library

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

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

    <activity android:name=".activities.MainActivity"/>
    
    0 讨论(0)
提交回复
热议问题