Android studio : Unresolved reference: drawable : Fixed
Below are the steps to replicate the Unresolved reference: drawable error and to fix the error.
Steps to replicate the error
- Create a new Compose project
Below is the default boilerplate code that will be generated on clicking Finish
Add a logo inside drawable folder. Then implement the logic to display image inside the Greeting composable
Now, when the Greeting composable is moved to a different file (GreetingScreen.kt), below error message is displayed
Solution to fix the error
This error occurs when the AndroidStudioIDE does not automatically insert the import statement into the new file when the code is moved to a different file.
Fix: add import com.demo.myapplication.R; statement in the GreetingScreen.kt