java.lang.RuntimeException: Unable to instantiate activity ComponentInfo

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

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

    SQLiteDatabase db = openOrCreateDatabase("DB", MODE_PRIVATE, null); //trying to perform function where you can only set up objects, primitives, etc
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
    ....
    }
    

    rather than this:

    SQLiteDatabase db;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
    db = openOrCreateDatabase("DB", MODE_PRIVATE, null);
    ....
    }
    

提交回复
热议问题