“R cannot be resolved” may have wrong build path or libraries import

后端 未结 2 1782

I know this question has been many times but trust me I have checked all. Most of the question suggests to remove import android.R , remove any error in the xml file

相关标签:
2条回答
  • 2020-12-12 03:52

    Make sure you installed the Android build tool form sdk manager

    project right click properties-> Java BuildPath select Library and add android-support.jar the follow these step.

    Go to Project->Properties->Java Build Path than select Order and export tab. Set android-support .jar library checked and up it into top of the list. And clean and rebuild..It works for most of the cases

    enter image description here

    0 讨论(0)
  • 2020-12-12 04:03

    Check the answer here and the thread here. Check if your layouts contain any errors (this has to be done manually or automatically only with Android Studio). Search for incorrectly closed tags like <string> - </string>.

    EDIT (taken from this thread):

    Cleaning a project removes all auto-generated files. Building the project it should automatically create them. When you Clean a project, there's an option to start a build immediately after clean up.

    Here's a few things you can try (did the same procedure after manually deleting the "gen" directory.

    • After you have deleted the gen directory, go to Project > Clean ...
    • You should have errors indicating that R cannot be resolved to a variable. Right click on your project from the Package Explorer and select Build Project. Be sure Build Automatically option is turned off (uncheck in Project > Build Automatically).
    • Errors regarding R should have now disappeared. Now, perform a Project Clean once again. All errors should be gone.
    0 讨论(0)
提交回复
热议问题