4

In my Android project app module, I have this: implementation 'androidx.appcompat:appcompat:1.5.0.

And my activity is class AppActivity : AppCompatActivity().

Then I changed my theme to material design by adding implementation 'com.google.android.material:material:1.8.0'

At this point I'm not sure if I should delete appcompat, I think I can't because AppCompatActivity comes from it. As I want to prove it, so I deleted implementation 'androidx.appcompat:appcompat:1.5.0, after sync all goes well.

Also I can check the AppCompatActivity is from appcompat:1.5.0(sorry for the image is not that clear)

enter image description here

So my question is where is it from as I have deleted it?

To find if it's from any other libraries, I tried add it back but upgrade it to 1.6.1: implementation 'androidx.appcompat:appcompat:1.6.1'

Then If it's using from any other libraries it should be still 1.5.0.

But I got:

enter image description here

Anyway to know about it? Thanks!

EDIT

As the accepted answer described, use Project structures -> Dependencies.

At the first I tried this too but didn't find out my answer, here I expand a bit more. e.g.

I selected: androidx.appcompat:appcompat:1.5.0 Then on the right side Target Module/Artifacts it shows your module you want to check where's it from. Here is my project image:

enter image description here

Then I know it's from material:1.8.0 I can delete appcompat anyway. It's not from 3rd party libraries.

William Hu
  • 15,423
  • 11
  • 100
  • 121
  • 1
    Check [dependency tree](https://stackoverflow.com/questions/39008887/how-do-i-show-dependencies-tree-in-android-studio). u can also exclude/force the version . – ADM Apr 07 '23 at 05:08
  • There might be situations where you'd want to declare a dependency explicitly, rather than depend on it via another dependency (aka transitive dependency). You can use https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin to check for transitive dependencies, among other things. – Alvin Dizon Apr 10 '23 at 09:33

2 Answers2

2

If using AndroidStudio, check this way. Go to project structure -> Dependencies -> <All Modules> scroll AppCompat library and click the undesired version, this should show you the detail dependencies.

enter image description here

Watermelon
  • 452
  • 2
  • 5
1

Maybe you implement two appcompat lib in your gradle file, or just gradle's cache. Here is a easy way to find out:

  1. First : Into the lib your depend on
  2. Second : Click this button in your Android Studio enter image description here
  3. You will see left of screen just like this enter image description here After this , you will find out with lib depended

Ops, I have two constaintlayout depend in my project enter image description here So, just need delete one of them in my gradle file

Godrick
  • 71
  • 5