Android - activity_main cannot be resolved or is not a field

后端 未结 11 1805
栀梦
栀梦 2020-12-05 05:40

Previous people have had the same error message, but the solution has always been to remove or modify some import \"android.R\". I have no such import so I\'m really lost

11条回答
  •  情话喂你
    2020-12-05 06:19

    1) Where does your layout file exist? is it under layout folder then shouldn't it be

    R.layout.activity_main
    

    2) You still have to import your projects R file

    com.example.mapssample.R;
    

    3) R file is automatically generated if there's no error in your code. Sometimes when you get can't resolve R file error means you have problem somewhere else in the project. Try clean project. It might help.

    4) You don't really need menu for testing this project. Also the activity_main file you showed is already included in the project and that's in layout folder. Just comment the menu part and see.

提交回复
热议问题