Home > Net >  Error on some imports on Android Studio for AppCompatActivity and androidx.appcompat.app.AppCompatAc
Error on some imports on Android Studio for AppCompatActivity and androidx.appcompat.app.AppCompatAc

Time:10-17

I was working in an android project and everything is ok, but when I try to open the project now, I got the some import errors. Take a look in the image below:

Text

The code still compiles and I was able to run it in the Android emulator, but I can't use the IDE auto complete because of this error.

How can I fix that?

EDIT: the problem appears to be related to the Android AppCompat implementation in this line below

implementation 'androidx.appcompat:appcompat:1.0.0'

I try to change it to

implementation 'androidx.appcompat:appcompat:1.5.1'

But it generate some conflicts with another plugins.

The I return the implementation to the old value, but now when I try to put the version 1.5.1, it generates the following error:

  Could not resolve androidx.appcompat:appcompat:1.5.0.
Required by:
  project :app

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

CodePudding user response:

Not sure if this would help but, I usually do any of the steps below when I encounter that kind of Android Studio issue.

  • clean/rebuild project
  • invalidate cache~restart
  • delete .idea folder inside the root project folder, and re-import or re-open project
  • delete .idea and .gradle folders inside the root project folder and re-import or re-open project

Afaik, deleting the generated folders is safe, it will just re-run all IDE and gradle configurations from the start.

CodePudding user response:

I am really not sure about this problem, but i think it's IDE error.

you can Clean Project and then Rebuild project. you will find it in Build tab. or you restarting Android Studio might solve your problem.

last option : you have to remove every dependency then sync after paste every dependency again and sync. You must need internet connection do this step.

I hope this will solve your error.

  • Related