Cannot resolve class of basic widget in xml

Viewed 1646

Happen on Android Studio Preview - Arctic Fox (2020.3.1) Beta 4.

enter image description here

I've tried literally everything from multiple questions on SO; Clean Build, Invalidate Caches and Restart, remove root project's .gradle and .idea, remove caches folder in .gradle, even remove and download Android Studio again, you name it.

It's been almost a day and still can't figure it out, please help, this is killing my motivation :(

6 Answers

I was facing the same problem with an old project written totally in Java. Adding the following dependency in the project gradle file solved the problem.

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"

I've finally managed to solve this problem myself.

The steps are to remove the current project --> clone the project again from git --> Re-import project and rebuild.

Android Studio is funny sometimes.

You can use this for imageView

<androidx.appcompat.widget.AppCompatImageView />

instead of

<ImageView />

and for textView use this

<androidx.appcompat.widget.AppCompatTextView />

instead of

<TextView />

In my case deleting ~/.gradle and invalidating caches did the trick.

I had the same issue that Android studio can't recognize the xml elements

ā›” Problem

Cannot resolve class layout
Element layout must be declared

āœ… Solution

Is the clear the cache of Android Studio

enter image description here

For me updating the kotlin version resolved that.

Related