Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio - Removed dependency is not removed from external libraries

In Android Studio, I'm implementing some libraries in the gradle file to be used in my app, these libraries got added to the external libraries section in the project, each with it's own version.

Now when I delete the dependency of one of these libraries from my gradle file, it's not getting deleted from the external libraries section, and it's extracted classes can be imported and used normally in the app, which is a big ques mark for me.

enter image description here

Also when changing one of these libraries version(downgrading at my case), the updated version is not getting reflected in the external libraries section, and instead, the version in the external libraries section is the one who is used in the app, which forces me to use a version that I don't want to use.

enter image description here

enter image description here

I've tried "build project" and even "invalidate and restart" but nothing changes, what am I missing here?!!

like image 541
Muhammed Refaat Avatar asked Sep 02 '25 11:09

Muhammed Refaat


2 Answers

in directory .idea/libraries there's a cached xml file, which has to be deleted.

also "invalidate caches and restart" should cause this to refresh.

Additionally, there are further caches; build directory/directories and ~/.gradle/caches in the user profile... or there might be some other module, which still has it referenced.

like image 109
Martin Zeitler Avatar answered Sep 04 '25 02:09

Martin Zeitler


The most likely explanation, and confirmed in comments of another answer, is that the library that was declared as a first level dependency also was a transitive dependency of another library.

Similarly for the version, when changing it on the first level dependency declaration, it was still upgraded to another version through a transitive dependency and conflict resolution.

like image 32
Louis Jacomet Avatar answered Sep 04 '25 00:09

Louis Jacomet