Cannot Resolve symbol R

后端 未结 8 1835
礼貌的吻别
礼貌的吻别 2021-01-18 07:02

I was working on Android Studio for adding a short toast message.(I was making an Android Wear Application)

I couldn\'t know why this code has error on \'symbol R\'

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-18 07:17

    Just in case any of the above answers don't work, the following solved the issue in my case...

    Here's what I tried:

    • Multiple "cleans", "rebuilds" and "invalidate caches restart"

    • Attempts to manually add [my package].R,

    This didn't work, so I uninstalled Android Studio, and reinstalled the latest version.

    The accepted answer to the above link has the following steps (which I reproduce here):

    1. Uninstall from installer. (via control panel for windows)
    2. Remove Android Studio files

      Go to your user folder (%USERPROFILE%), and delete .android, .AndroidStudio and any analogous directories with versions on the end, i.e. .AndroidStudio1.2, as well as .gradle and .m2 if they exist. Then go to %APPDATA% and delete the JetBrains directory. Finally, go to C:\Program Files and delete the Android directory.

    3. Remove the SDK

      To delete any remains of the SDK, go to %LOCALAPPDATA% and delete the Android directory.

    4. Delete Android Studio Projects

      Android Studio creates projects in a folder %USERPROFILE%\AndroidStudioProjects, which you may want to delete.

    I skipped 4), then uninstalled a separate Java 7 installation I had, for good measure.

    Next I downloaded the latest Android Studio (3.3.2) and installed it.

    A bit drastic perhaps, but now everything is working and the "Cannot resolve symbol R" error is gone.

提交回复
热议问题