Fixed
Status Update
Comments
yb...@google.com <yb...@google.com> #2
Tor, in data binding, we depend on an old version of support library so that gradle picks whatever app uses (since gradle picks the latest by default).
If this is a new linter, can we ignore data binding or is there sth we can do on the data binding side ?
If this is a new linter, can we ignore data binding or is there sth we can do on the data binding side ?
tn...@google.com <tn...@google.com> #3
Hmmm, I can't reproduce this.
I created a simple project, added data binding, added a recycler view dependency, set the Gradle plugin version to 2.3.0-alpha2, and ran lint. I don't get that warning. When I deliberately make the versions inconsistent (e.g appcompat 25.0.1 and recyclerview 25.0.0), it *does* warn.
And my dependency graph looks similar to yours -- there's a 21.x version dependency from the data binding library, but lint correctly uses the promoted version instead:
+--- com.android.support:appcompat-v7:25.0.1
| +--- com.android.support:support-v4:25.0.1
| | +--- com.android.support:support-compat:25.0.1
| | | \--- com.android.support:support-annotations:25.0.1
| | +--- com.android.support:support-media-compat:25.0.1
| | | \--- com.android.support:support-compat:25.0.1 (*)
| | +--- com.android.support:support-core-utils:25.0.1
| | | \--- com.android.support:support-compat:25.0.1 (*)
| | +--- com.android.support:support-core-ui:25.0.1
| | | \--- com.android.support:support-compat:25.0.1 (*)
| | \--- com.android.support:support-fragment:25.0.1
| | +--- com.android.support:support-compat:25.0.1 (*)
| | +--- com.android.support:support-media-compat:25.0.1 (*)
| | +--- com.android.support:support-core-ui:25.0.1 (*)
| | \--- com.android.support:support-core-utils:25.0.1 (*)
| +--- com.android.support:support-vector-drawable:25.0.1
| | \--- com.android.support:support-compat:25.0.1 (*)
| \--- com.android.support:animated-vector-drawable:25.0.1
| \--- com.android.support:support-vector-drawable:25.0.1 (*)
+--- com.android.support.constraint:constraint-layout:1.0.0-beta4
| \--- com.android.support.constraint:constraint-layout-solver:1.0.0-beta4
+--- com.android.support:recyclerview-v7:25.0.1
| +--- com.android.support:support-annotations:25.0.1
| +--- com.android.support:support-compat:25.0.1 (*)
| \--- com.android.support:support-core-ui:25.0.1 (*)
+--- com.android.databinding:library:1.3.1
| +--- com.android.support:support-v4:21.0.3 -> 25.0.1 (*)
| \--- com.android.databinding:baseLibrary:2.3.0-dev -> 2.3.0-alpha2
+--- com.android.databinding:baseLibrary:2.3.0-alpha2
\--- com.android.databinding:adapters:1.3.1
+--- com.android.databinding:library:1.3 -> 1.3.1 (*)
\--- com.android.databinding:baseLibrary:2.3.0-dev -> 2.3.0-alpha2
Test project attached. Any other clues to reproducing this?
I created a simple project, added data binding, added a recycler view dependency, set the Gradle plugin version to 2.3.0-alpha2, and ran lint. I don't get that warning. When I deliberately make the versions inconsistent (e.g appcompat 25.0.1 and recyclerview 25.0.0), it *does* warn.
And my dependency graph looks similar to yours -- there's a 21.x version dependency from the data binding library, but lint correctly uses the promoted version instead:
+--- com.android.support:appcompat-v7:25.0.1
| +--- com.android.support:support-v4:25.0.1
| | +--- com.android.support:support-compat:25.0.1
| | | \--- com.android.support:support-annotations:25.0.1
| | +--- com.android.support:support-media-compat:25.0.1
| | | \--- com.android.support:support-compat:25.0.1 (*)
| | +--- com.android.support:support-core-utils:25.0.1
| | | \--- com.android.support:support-compat:25.0.1 (*)
| | +--- com.android.support:support-core-ui:25.0.1
| | | \--- com.android.support:support-compat:25.0.1 (*)
| | \--- com.android.support:support-fragment:25.0.1
| | +--- com.android.support:support-compat:25.0.1 (*)
| | +--- com.android.support:support-media-compat:25.0.1 (*)
| | +--- com.android.support:support-core-ui:25.0.1 (*)
| | \--- com.android.support:support-core-utils:25.0.1 (*)
| +--- com.android.support:support-vector-drawable:25.0.1
| | \--- com.android.support:support-compat:25.0.1 (*)
| \--- com.android.support:animated-vector-drawable:25.0.1
| \--- com.android.support:support-vector-drawable:25.0.1 (*)
+--- com.android.support.constraint:constraint-layout:1.0.0-beta4
| \--- com.android.support.constraint:constraint-layout-solver:1.0.0-beta4
+--- com.android.support:recyclerview-v7:25.0.1
| +--- com.android.support:support-annotations:25.0.1
| +--- com.android.support:support-compat:25.0.1 (*)
| \--- com.android.support:support-core-ui:25.0.1 (*)
+--- com.android.databinding:library:1.3.1
| +--- com.android.support:support-v4:21.0.3 -> 25.0.1 (*)
| \--- com.android.databinding:baseLibrary:2.3.0-dev -> 2.3.0-alpha2
+--- com.android.databinding:baseLibrary:2.3.0-alpha2
\--- com.android.databinding:adapters:1.3.1
+--- com.android.databinding:library:1.3 -> 1.3.1 (*)
\--- com.android.databinding:baseLibrary:2.3.0-dev -> 2.3.0-alpha2
Test project attached. Any other clues to reproducing this?
tn...@google.com <tn...@google.com> #4
Interestingly, in *my* case, it looks like Gradle promoted support-v4 from 21.0.3 to 25.0.1:
+--- com.android.databinding:library:1.3.1
| +--- com.android.support:support-v4:21.0.3 -> 25.0.1 (*)
However, in your dependency graph, it does not:
+--- com.android.databinding:library:1.3.1
| +--- com.android.support:support-v4:21.0.3
+--- com.android.databinding:library:1.3.1
| +--- com.android.support:support-v4:21.0.3 -> 25.0.1 (*)
However, in your dependency graph, it does not:
+--- com.android.databinding:library:1.3.1
| +--- com.android.support:support-v4:21.0.3
tn...@google.com <tn...@google.com> #5
Actually when I strip out the other stuff that a default project includes (appcompat and junit+espresso etc) then I can reproduce it!
And I see the problem. In my default project, I was using appcompat 25, which depends on support-v4 25. But in your project, with *only* recyclerview and data binding, there's actually no explicit dependency on support-v4 --- there's only the implicit dependency via the data library, so you're *actually* using the old support-v4 (version 21) project!
If you add an *explicit* dependency on the newer version of the support-v4 library, e.g.
dependencies {
compile 'com.android.support:recyclerview-v7:25.0.0'
compile 'com.android.support:support-v4:25.0.0'
}
THEN things work properly; Gradle now shows that the dependency will be promoted:
+--- com.android.databinding:library:1.3.1
| +--- com.android.support:support-v4:21.0.3 -> 25.0.0 (*)
So, I think this is actually a good thing -- lint is pointing out that you *are* using an older version which is potentially incompatible with recyclerview. I know that's kinda unlikely with recyclerview specifically.
Maybe I should just try to make the error message better and special case this case in particular (e.g. if I see that the inconsistency is with some old support-v4 version, and that you're using data binding, suggest adding an explicit support-v4 dependency with the higher version number?
And I see the problem. In my default project, I was using appcompat 25, which depends on support-v4 25. But in your project, with *only* recyclerview and data binding, there's actually no explicit dependency on support-v4 --- there's only the implicit dependency via the data library, so you're *actually* using the old support-v4 (version 21) project!
If you add an *explicit* dependency on the newer version of the support-v4 library, e.g.
dependencies {
compile 'com.android.support:recyclerview-v7:25.0.0'
compile 'com.android.support:support-v4:25.0.0'
}
THEN things work properly; Gradle now shows that the dependency will be promoted:
+--- com.android.databinding:library:1.3.1
| +--- com.android.support:support-v4:21.0.3 -> 25.0.0 (*)
So, I think this is actually a good thing -- lint is pointing out that you *are* using an older version which is potentially incompatible with recyclerview. I know that's kinda unlikely with recyclerview specifically.
Maybe I should just try to make the error message better and special case this case in particular (e.g. if I see that the inconsistency is with some old support-v4 version, and that you're using data binding, suggest adding an explicit support-v4 dependency with the higher version number?
yb...@google.com <yb...@google.com> #6
i think it will be nice to change linter to give a solution as you've mentioned.
Also, we should change data binding to start depending on individual components of support (fyi, support v4 has been divided which is probably causing this issue).
Also, we should change data binding to start depending on individual components of support (fyi, support v4 has been divided which is probably causing this issue).
tn...@google.com <tn...@google.com> #7
The dependency graph above shows exactly that division :-)
tn...@google.com <tn...@google.com> #8
Fixed in 2.4 preview 2 by change id Ib862927793c9848f673308f30f303b0fc17f6293. (Checked in too late for preview 1.)
Here's the new error message you get in this scenario:
build.gradle:3: Error: All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.0.0, 21.0.3. Examples include com.android.support:recyclerview-v7:25.0.0 and com.android.support:support-v4:21.0.3. Note that this project is using data binding (com.android.databinding:library:1.3.1) which pulls in com.android.support:support-v4:21.0.3. You can try to work around this by adding an explicit dependency on com.android.support:support-v4:25.0.0 [GradleCompatible]
compile "com.android.support:recyclerview-v7:25.0.0"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 errors, 0 warnings
Here's the new error message you get in this scenario:
build.gradle:3: Error: All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.0.0, 21.0.3. Examples include com.android.support:recyclerview-v7:25.0.0 and com.android.support:support-v4:21.0.3. Note that this project is using data binding (com.android.databinding:library:1.3.1) which pulls in com.android.support:support-v4:21.0.3. You can try to work around this by adding an explicit dependency on com.android.support:support-v4:25.0.0 [GradleCompatible]
compile "com.android.support:recyclerview-v7:25.0.0"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 errors, 0 warnings
is...@gmail.com <is...@gmail.com> #9
[Comment deleted]
is...@gmail.com <is...@gmail.com> #10
In my case nothing works, I had to erase everything and reinstall android studio and SDK but not update the gradle -.-'
Description
"All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.0.0, 21.0.3. Examples include com.android.support:recyclerview-v7:25.0.0 and com.android.support:support-v4:21.0.3"
I only added one dependency — RecyclerView. My expectation: no lint error!
I'm using Android Studio 2.3 canary v2, and gradle 2.3.0-alpha2.
In my app's build.gradle:
dependencies {
compile 'com.android.support:recyclerview-v7:25.0.0'
}
If I run ./gradlew dependencies this is the only place I see 21.0.3.
default - Configuration for default artifacts.
+--- com.android.support:recyclerview-v7:25.0.0
| +--- com.android.support:support-annotations:25.0.0
| +--- com.android.support:support-compat:25.0.0
| | \--- com.android.support:support-annotations:25.0.0
| \--- com.android.support:support-core-ui:25.0.0
| \--- com.android.support:support-compat:25.0.0 (*)
+--- com.android.databinding:library:1.3.1
| +--- com.android.support:support-v4:21.0.3
| | \--- com.android.support:support-annotations:21.0.3 -> 25.0.0
| \--- com.android.databinding:baseLibrary:2.3.0-dev -> 2.3.0-alpha2
+--- com.android.databinding:baseLibrary:2.3.0-alpha2
\--- com.android.databinding:adapters:1.3.1
+--- com.android.databinding:library:1.3 -> 1.3.1 (*)
\--- com.android.databinding:baseLibrary:2.3.0-dev -> 2.3.0-alpha2