Rahul Khatri
Rahul Khatri

Reputation: 1620

What is the use of androidx.legacy:legacy-support-v4: dependency

I was implementing Android Room Database and in one of the tutorial I found the usage of androidx.legacy:legacy-support-v4:1.0.0 dependency. Can any one tell me use of this dependency.

Upvotes: 54

Views: 41503

Answers (3)

Steve
Steve

Reputation: 561

None of the answers seem to say what this specific dependency offers. From what I can see it is nothing but a convenience artifact whose dependencies will pull in a few choice androidx dependencies for you. Probably meant to be some sort of helper until one eventually migrates to directly declaring these individual dependencies.

https://maven.google.com/web/index.html?#androidx.legacy:legacy-support-v4:1.0.0

Viewing the pom linked from here shows it will pull these in.

<dependencies>
<dependency>
  <groupId>androidx.core</groupId>
  <artifactId>core</artifactId>
  <version>1.0.0</version>
  <type>aar</type>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>androidx.media</groupId>
  <artifactId>media</artifactId>
  <version>1.0.0</version>
  <type>aar</type>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>androidx.legacy</groupId>
  <artifactId>legacy-support-core-utils</artifactId>
  <version>1.0.0</version>
  <type>aar</type>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>androidx.legacy</groupId>
  <artifactId>legacy-support-core-ui</artifactId>
  <version>1.0.0</version>
  <type>aar</type>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>androidx.fragment</groupId>
  <artifactId>fragment</artifactId>
  <version>1.0.0</version>
  <type>aar</type>
  <scope>compile</scope>
</dependency>

Upvotes: 0

Filipe Bezerra de Sousa
Filipe Bezerra de Sousa

Reputation: 3052

An important hint from the docs

Note: With the release of Android 9.0 (API level 28) there is a new version of the support library called AndroidX which is part of Jetpack. The AndroidX library contains the existing support library and also includes the latest Jetpack components.

You can continue to use the support library. Historical artifacts (those versioned 27 and earlier, and packaged as android.support.*) will remain available on Google Maven. However, all new library development will occur in the AndroidX library.

We recommend using the AndroidX libraries in all new projects. You should also consider migrating existing projects to AndroidX as well.

Upvotes: 5

Jakir Hossain
Jakir Hossain

Reputation: 3930

androidx.legacy:legacy-support-v4 is Androidx artifacts of com.android.support:support-v4

com.android.support:support-v13 -> androidx.legacy:legacy-support-v13 com.android.support:support-v4 -> androidx.legacy:legacy-support-v4

You can find info about the library mapping here

The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren't a part of the framework APIs. Compatible on devices running API 14 or later.

Uses for the Support Libraries

There are a few distinct uses for the support libraries. Backward compatibility classes for earlier versions of the platform is just one of them.

  • Backward Compatibility for newer APIs - A large amount of the support libraries provide backward compatibility for newer framework classes and methods. For example, the Fragment support class provides support for fragments on devices running versions earlier than Android 3.0 (API level 11).
  • Convenience and Helper Classes - The support libraries provides a number of helper classes, particularly for user interface development. For example, the RecyclerView class provides a user interface widget for displaying and managing very long lists, useable on versions of Android from API level 7 and up.
  • Debugging and Utilities - There are a number of features that provide utility beyond code you incorporate into your app, including the support-annotations library for improved code lint checks on method inputs and Multidex support for configuring and distributing apps with over 65,536 methods.

See official documents here support-library

Upvotes: 38

Related Questions