Search code examples
androidandroid-studiodependenciesandroid-constraintlayoutandroid-appcompat

Class referenced in the layout file, `androidx.constraintlayout.widget`, was not found in the project or the libraries


hey everyone btw it's my first question in StackOverflow hope you help me find the answer. I tried to add recycler view to my android studio arctic fox v2020.3.1 from tab File>Project Structure > Dependencies. then l clicked on the + button to add "androidx.recyclerview:recyclerview:1.2.1" to my app and I`ve searched and applied it then I came back to using it and I noticed thousands of redlines under every code and most of them couldn't find or resolve something as below:errors 1 errors 2

I tried to delete dependencies and recall them nothing happened I also tried restarting Android Studio, nothing I use the latest JDK and etc

code with error


Solution

  • for all of those that are faced with this problem I hope this helps you because I fixed it with toggle offline mode of Gradle somehow my Gradle version changed during few days of using it in offline mode and I`ve forgotten that to change it back so when I was trying to add new dependency it comes with this problem and you can fix it by clicking on Gradle tab, switching off the toggle and syncing your project with Gradle files again.

    thanks to those who wanted to help.