Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Support library version

I try to inject support libraries into my Android Studio project.

If I try anything lower than 20 it says: library should not use a lower version then targetSdk version.

If I use compile 'com.android.support:support-v4:20' I get: Failed to find: com.android.support:support-v4:20

If I use compile 'com.android.support:support-v7:20.0.+' I get: Avoid using + in version numbers, can lead to unpredictable and unrepeatable builds.

So the simple question is: where can I find up-to-date, ready to use, version numbers that Do work?

like image 347
TomCB Avatar asked Aug 24 '14 12:08

TomCB


People also ask

What is the support library?

The Android Support Library package is a set of code libraries that provide backward-compatible versions of Android framework APIs as well as features that are only available through the library APIs. Each Support Library is backward-compatible to a specific Android API level.

Is the latest version of the Legacy Support library?

Version 28(intended for Android Pie and below) is the last version of the legacy support library, so we recomand that you migrate to AndroidX libraies when using Android Q and moving forward. AndroidX replaces the original support library APIs with packages in the androidx namespace.


2 Answers

If I try anything lower than 20 it says: library should not use a lower version then targetSdk version.

That is because you set your targetSdkVersion to something higher than 19. If you did so intentionally, fine. If you did not do so intentionally, consider dropping it back to 19 for now, and use compile 'com.android.support:support-v4:19.1.0' (if you are using the backport of fragments) or compile 'com.android.support:support-v13:19.1.0' (if you are not using the backport of fragments).

If I use compile 'com.android.support:support-v4:20' I get: Failed to find: com.android.support:support-v4:20

That is because the Android Support package uses X.Y.Z semantic versioning, as do most artifacts in repositories. 20 does not match the X.Y.Z pattern.

If I use compile 'com.android.support:support-v7:20.0.+' I get: Avoid using + in version numbers, can lead to unpredictable and unrepeatable builds.

That is merely a warning. If you are using version control for your project files, and you feel that it is important to be able to check out some earlier version of your code and be able to reproduce that build, then using the + notation is not a good idea. OTOH, if being able to reproduce historical builds is not essential, using the + wildcard, as you are doing, ensures that you get updates automatically. Having the + in the third position (Z in X.Y.Z) means that you will automatically get patchlevel updates.

where can I find up-to-date, ready to use, version numbers that Do work?

On your hard drive, in $ANDROID_SDK/opt/extras/android/m2repository/com/android/support/$LIBRARY/, where $ANDROID_SDK is wherever you installed the Android SDK and $LIBRARY is whichever Android Support package library you are interested in (e.g., support-v13).

like image 132
CommonsWare Avatar answered Sep 28 '22 05:09

CommonsWare


To see the current Android Support Library revision number ...

  • Android Studio > Tools > Android > SDK Manager ...
  • Extras > Android Support Library: See the Rev. number e.g. (21.0.3).

For a quick insertion of the right revision number when in your gradle file you currently have something like 'com.android.support:appcompat-v7:21.0.+' with the 'Avoid using + in version numbers ...' warning, use the relevant IntelliJ Inspection ...

  • Place your cursor over 'com.android.support:appcompat-v7:21.0.+' (anywhere in the colored section of the warning).
  • Alt + Enter > "Replace with specific version".

There are plans to include the latest specific version number in the warning. See Issue 78737: Have the "Avoid using + in version numbers" gradle library warning suggest the version currently in use.

like image 43
John Bentley Avatar answered Sep 28 '22 04:09

John Bentley