Shubham Anand
Shubham Anand

Reputation: 621

Cannot Resolve class TextView in xml file

I just changed my Laptop, downloaded Android Studio Arctic Fox and cloned the project on which I was already working on in my previous machine. I see that few of the tags are not imported and are in red in the xml layout. When I hover over it, it says "Cannot resolve class TextView". Similar issue with ImageView. What is wrong?

enter image description here

Upvotes: 8

Views: 9702

Answers (7)

Duy229
Duy229

Reputation: 1

I think It's because the lottie version in gradle. When I start a new project, it's resolve if I use lottie:6.4.0 but when I run my last year project, I have to use lottie:3.4.0

Upvotes: 0

RISHI Soni
RISHI Soni

Reputation: 1

I also faced this issue and i after consideration there can be

1)problem in your gradle version(which is not in my case)

2)I am writing code below this line

</androidx.constraintlayout.widget.ConstraintLayout> 

write all your code above this.

which caused trouble.

Upvotes: 0

AndroidLearnDay
AndroidLearnDay

Reputation: 1

I solved this error by set Gradle user home : 1.File -〉Project Structure -〉SDK Location -〉Gradle Setting -〉Gradle user home (select your local)

Upvotes: 0

Berthold Bawouke
Berthold Bawouke

Reputation: 1

This error but made a struggle 3 days; I solved it by upgrading gradle to the latest version on this day gradle: 7.0.3 at the classpath level (build.gradle (project))

Upvotes: 0

Sohag
Sohag

Reputation: 79

I also facing the same problem for 2 days, try lots of the way but didn't work. But a few minutes ago I just update my Glradle to the

classpath 'com.android.tools.build:gradle:7.0.1'

and boom it's solved my problem. You can try this :)

Upvotes: 4

Niraj Niroula
Niraj Niroula

Reputation: 2424

Most probably, you might have been using androidx libraries.
Try androidx.appcompat.widget.AppCompatTextView

instead of <TextView

Upvotes: -1

viranga LH
viranga LH

Reputation: 38

after clean the project sync the build gradle or cut and paste a one dependency and sync the gradle

Upvotes: 1

Related Questions