“Cannot find symbol R” error after renaming package name

后端 未结 8 2378
深忆病人
深忆病人 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:23

    Just do the following:

    Ensure that the package name at the header of the AndroidManifest file has been renamed to your new package name. This worked for me.

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

    if you rename your android manifest package you have to rename the "packages com.newname" sentence at the beginning of your class.

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

    You have to first close android studio. Then

    1. Delete "build" folder
    2. open the commandline and type gradlew clean
    3. Then type gradlew assembledebug
    4. If the build succeeds, feel free to go back to android studio
    0 讨论(0)
  • 2021-02-07 05:26

    3 packages you may see as marked, When you edit the package name make sure you change all 3 of them else you may face R error which will prompt you to press alt+enter to name it as ur old package name

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

    Try to change application Id in build.gradle. Or remove any imports of com.***.R in your activity and let android studio to automatically import for you.

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

    Try the following :

    Try deleting your R.java file , android studio will regenerate it.

    Clean Project

    Rebuild Project

    And check:

    Check the AndroidManifest.xml, there's a package attribute on the top-level element

    (Well it depends on how you renamed your package name)

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