Different Ways to fix “cannot resolve symbol R” in Android Studio

In an android application we can use kt or java class but both must have an import R file. Create new activity automatically import R file otherwise manually  Alt + Enter to import file. R stands for the resource. This error occurs because of the incapability to build the project . 

Most common error is “R can not be resolved” error appears if there is an issue with some of your resource files. you are unable  to build  this project on mobile application

Method 1 

Try the sync Gradle .Just follow this path File > Sync project with Gradle files.



Method 2

Make sure your package name is correct in AndroidManifest.xml Sometime R file not generated of package name in Android Manifest does not match with module package name. 

Method 3

   Step 1: Clean the project

     To clean project  : Click on build > clean project



   Step 2: Rebuild project

     Click on Build and click on  rebuild project.



Method 4: Try Invalidate caches and restart  file > Invalidate caches/restart




Happy coding!




















365Bloggy May 22, 2024
Share this post
Tags
SUBSCRIBE THIS FORM


Archive