Android - activity_main cannot be resolved or is not a field

后端 未结 11 1710
栀梦
栀梦 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:28

    Try the following

    com.example.mapssample.R.layout.activity_main
    
    0 讨论(0)
  • 2020-12-05 06:32

    I have three ways that help me to solve this problem, may be it works for you.

    1. first clean than try to import your project like this: import com.example.mapssample.R;
    2. right click on project go to properties--> android --> select target.
    3. clean
    0 讨论(0)
  • 2020-12-05 06:36

    Heh.. similar prob.. turns out somewhere along the line I had renamed the map fragment ID in the XML layout file.. Was looking for a fragment ID that did not exists.. hope it helps someone else.

    0 讨论(0)
  • 2020-12-05 06:37

    Your Code imported android.R so first remove this line import android.R;

    so remove this line & press cntrl+shift+o (to import necessary packages)..

    0 讨论(0)
  • 2020-12-05 06:38

    the activity_main.xml file maybe is wrong.I mean there is some weird symbol error inside the file.you shold check it out.

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