Android gradle: what do the square brackets around the version mean?

In Android Android apps Android sdk, you'll find two ways to add dependency to your project. In the Getting Started section, the line in gradle is

compile 'com.facebook.android:facebook-android-sdk:4.+' 

but in the quick start guide line

 compile 'com.facebook.android:facebook-android-sdk:[4,5)' 

In addition, Android Studio warns that you should not use "+" in version numbers, which leads to unique builds. I saw a “+” for other dependencies, and I believe that this means getting the latest version when gradle synchronizes, but what does the square bracket and brackets in the second line mean?

+11
android gradle
source share
3 answers

That means range. [means inclusion,) means to. Thus, it will be any version starting from 4, but less than 5. so that 4.0, 4.1, 4.99999.9999 will correspond, 5.0 will not. 4. + means anything 4 or more without an upper bound.

+15
source share

@GabeSechan is something weird, although I have:

 implementation 'com.facebook.android:facebook-android-sdk:[4,5)' 

In Android studio, I get a warning:

A newer version of com.facebook.android:facebook-android-sdk is available than [4,5]: 4.38.1

this means that [4,5] does not necessarily import the latest version into the SDK

0
source share

for example

0.1 _ 0.3 _ 1.0 _ 1.1 _ :[0,1) → 0.3 _ 1.2 _ :[1,2) → 1.2 _ 1.3 → -> 1.3 _ 1.4 → -> 1.4

0
source share

All Articles