First check the name of your XML layout ( YourProject/res/layout/your_main.xml in your project folder).
replace:
setContentView(R.layout.**Main**);
with:
setContentView(R.layout.**your_main**);
Mine was activity_main .xml, which I replaced with " main ".
I'm just a beginner. Maybe I'm wrong, but that solved my problem.
source share