TomCB TomCB - 1 month ago 20
Android Question

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?

Answer

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).