-3

I am making an Android app. Due to some reasons, my current project files got all messed up. To solve this issue I created a new project in Android Studio and copied the files from the previous project to this new project.

I carefully copied all the layout, values, java files at their right location. I replaced the relavant content from the new manifest and gradle files with new content.

Everything looked perfect and then I got the "Cannot resolve symbol R" error.

I tried all the solutions like Invalidate Cache/Restart, Sync files with gradle, Rebuild Project, Clean Project etc. etc. etc.

Still couldn't fix it.

Can someone help?

Edit

Problem Details 1. I have correct package name everywhere (in AndroidManifest too) 2. I have proper and valid xml files 3. Even if I copied the files from other project the I've kept the project name and package names exactly the same. 4. I have only one app module.

Nishat sAyyed
  • 111
  • 1
  • 8
  • 3
    Something's failing during the resource build. Look carefully through everything under the `res/` folder to check for any files that might have errors. – Mike M. Mar 26 '19 at 10:13
  • 2
    Possible duplicate of [R cannot be resolved - Android error](https://stackoverflow.com/questions/885009/r-cannot-be-resolved-android-error) – Gourav Mar 26 '19 at 11:00

3 Answers3

0

Try to remove .R line from every java class .

Talha Bilal
  • 127
  • 7
0

You might have an error in one of your xml files, like a duplicated xml header. Check for every single one.

You can also update Android Studio as it now tells you the file and location of the error.

P Fuster
  • 1,901
  • 16
  • 27
0

I strongly suggest you copy and paste your codes to individual right places if you want to move these to a new project. Copying folders and files to a newly created project would not work as there could be some lines that include your old folder paths

For example, your old project was in C://StudioProjects/YourProjectName so your codes should be in C://StudioProjects/YourProjectName/app/src/main/java/com/example/AppName but if you directly copy a file or folder to a newly created project, you could end up referencing the wrong path like C://StudioProjects/YourProjectName/app/src/main/java/com/example/NewAppName and this could blow your XML file which will lead to R cannot resolve symbol R.

Even though you put your folders in the same path, reference numbers changed in the new project.

Hur T.
  • 3
  • 3