Android Studio Marks R in Red with Error Message "Cannot Resolve Symbol R", But Build Succeeds

Android Studio marks R in red with error message cannot resolve symbol R , but build succeeds

Here is my temporary solution until I find a better one:

  1. Using Everything, find where R.java is created. In my case it was
    C:\Program Files (x86)\Android\android-studio\system\compiler\<project-name>.cb969c52\.generated\aapt\<module-name>.6badd9a4\production\com\<project-name>\<module-name>

  2. In the Project view, click the module and press F4. Ignore the warning.

  3. Click "+ Add Content Root" and select the aforementioned folder. Make sure it's marked in blue (as a source).

After I did this, suddenly all the warnings are gone. The problem is that if you collaborate with other people, the folder name is different on each machine so be careful when synchronizing.

Android Studio marks R in red with error message cannot resolve symbol R , but build succeeds

Here is my temporary solution until I find a better one:

  1. Using Everything, find where R.java is created. In my case it was
    C:\Program Files (x86)\Android\android-studio\system\compiler\<project-name>.cb969c52\.generated\aapt\<module-name>.6badd9a4\production\com\<project-name>\<module-name>

  2. In the Project view, click the module and press F4. Ignore the warning.

  3. Click "+ Add Content Root" and select the aforementioned folder. Make sure it's marked in blue (as a source).

After I did this, suddenly all the warnings are gone. The problem is that if you collaborate with other people, the folder name is different on each machine so be careful when synchronizing.

Android Studio marks R in red with error message cannot resolve symbol R , but build succeeds

Here is my temporary solution until I find a better one:

  1. Using Everything, find where R.java is created. In my case it was
    C:\Program Files (x86)\Android\android-studio\system\compiler\<project-name>.cb969c52\.generated\aapt\<module-name>.6badd9a4\production\com\<project-name>\<module-name>

  2. In the Project view, click the module and press F4. Ignore the warning.

  3. Click "+ Add Content Root" and select the aforementioned folder. Make sure it's marked in blue (as a source).

After I did this, suddenly all the warnings are gone. The problem is that if you collaborate with other people, the folder name is different on each machine so be careful when synchronizing.



Related Topics



Leave a reply



Submit