Androidx dependencies

Every modern android project using android studio, will have the following dependencies added by default:

  • implementation 'androidx.appcompat:appcompat:'
  • implementation 'androidx.core:core-ktx:'
  • implementation 'androidx.constraintlayout:constraintlayout:'
Also, using specific classes requires adding their corresponding dependencies (like recyclerview for example)

My Question is : how are we able to use directly the class that comes from the androidx.fragment , without adding the necessary dependency:
implementation "androidx.fragment:fragment:$fragment_version"

I apologize for my delay in responding — I was out of the office for a few days.

If your app is depending directly upon androidx.appcompat:appcompat, then you are pulling in many other libraries as transitive dependencies. Basically, androidx.appcompat:appcompat declares that it depends on other libraries, so Gradle will add those to your project automatically.

In my AndroidX Tech site, you can find out the transitive dependencies for a given library, such as androidx.appcompat:appcompat:1.1.0:

There, you will see that it depends upon androidx.fragment:fragment:1.1.0, among other libraries. Gradle handles these transitive dependencies for you, making their contents available in your app automatically.