0

I am learning to work with the camerax library in Android on Google codelab.

They have an incomplete code for the project with which we have to work.

I did everything as instructed, and I think nothing is wrong from my side but still, the code is giving error: unresolved reference for activity_main and app_name.

What could be the possible reasons? I have tried 're-building' the project and restarting the Android studio. Image is added.enter image description here

Akr
  • 117
  • 2
  • 10
  • Check the import for R . You must have imported wrong R . – ADM Jan 22 '22 at 12:18
  • I have used this to import R: import kotlinx.android.synthetic.main.activity_main.* – Akr Jan 22 '22 at 12:21
  • 1
    Thats not R import . Its should be `import your_application_package_name.R`. – ADM Jan 22 '22 at 12:23
  • Thank you that solved my problem. Can you tell me more about R, resources? There are many so why there are many R? – Akr Jan 22 '22 at 12:27

1 Answers1

0

This is a common issue caused when you import the wrong R. Check your imports as @ADM already commented.

  • I have used this to import R: import kotlinx.android.synthetic.main.activity_main.* – Akr Jan 22 '22 at 12:23
  • 1
    https://stackoverflow.com/questions/51621301/android-studio-3-1-3-unresolved-reference-r-kotlin check out this thread. Might get some answers. – Arjis Chakraborty Jan 22 '22 at 16:54