“Cannot find symbol R” error after renaming package name

后端 未结 8 2379
深忆病人
深忆病人 2021-02-07 05:06

After renaming my project package name (with Refactor), I got this error:

Error:(7, 44) error: cannot find symbol class R

All of my R

相关标签:
8条回答
  • 2021-02-07 05:35

    Seems like, you changed the application package name but didn't change the import statements. So look for import statement of class R. It must be like

    import <package_name>.R;
    

    If it's not a problem with import statements then look whether the R.java file has generated or not. It generally doesn't get generated if there is a problem with the application layout(xml) files. The R class file is generated only when all your xml layout files are correct.

    Clean the project and check.

    0 讨论(0)
  • 2021-02-07 05:40

    In my case, this error showed because I changed the package name without ticking the boxes (Search in comments and strings and Search for text occurrences)

    The solution for me: Rename package again and make sure you tick the two boxes as in the photo, then Do Refactor

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