Google Dagger com.android.support:support-v4依赖版本

时间:2017-07-04 04:42:11

标签: android dagger-2

在针对Api 23(6.0)编译的应用程序中,我在build.gradle文件中收到一条警告:“所有com.android.support库必须使用完全相同的版本规范”,版本24.2.0&找到了23.1.1。

我的com.android.support依赖项都指定23.1.1但运行:

gradlew -q dependencies app:dependencies --configuration compile

显示这些都已升级到24.2.0。

唯一的例外是

com.google.dagger:dagger-android:2.9 

似乎依赖于

com.android.support:support-v4:24.2.0

gradlew依赖性报告的摘录:

+--- project :AppCommon
|    +--- com.android.support:appcompat-v7:23.1.1
|    |    \--- com.android.support:support-v4:23.1.1 -> 24.2.0
|    |         +--- com.android.support:support-compat:24.2.0
|    |         |    \--- com.android.support:support-annotations:24.2.0
|    |         +--- com.android.support:support-core-utils:24.2.0
|    |         |    \--- com.android.support:support-compat:24.2.0 (*)
|    |         +--- com.android.support:support-media-compat:24.2.0
|    |         |    \--- com.android.support:support-compat:24.2.0 (*)
|    |         +--- com.android.support:support-core-ui:24.2.0
|    |         |    \--- com.android.support:support-compat:24.2.0 (*)
|    |         \--- com.android.support:support-fragment:24.2.0
|    |              +--- com.android.support:support-compat:24.2.0 (*)
|    |              +--- com.android.support:support-core-utils:24.2.0 (*)
|    |              +--- com.android.support:support-media-compat:24.2.0 (*)
|    |              \--- com.android.support:support-core-ui:24.2.0 (*)
|    +--- com.android.support:support-v4:23.1.1 -> 24.2.0 (*)
|    +--- com.android.support:design:23.1.1
|    |    +--- com.android.support:appcompat-v7:23.1.1 (*)
|    |    +--- com.android.support:recyclerview-v7:23.1.1
|    |    |    +--- com.android.support:support-annotations:23.1.1 -> 24.2.0
|    |    |    \--- com.android.support:support-v4:23.1.1 -> 24.2.0 (*)
|    |    \--- com.android.support:support-v4:23.1.1 -> 24.2.0 (*)




|    \--- com.google.dagger:dagger-android:2.9
|         +--- com.google.dagger:dagger:2.9 (*)
|         +--- com.android.support:support-v4:24.2.0 (*)
|         \--- com.android.support:support-annotations:24.2.0

除了通过更改针对api 24的编译(并将所有com.android.support版本更改为24.2.0)之外,如何解决此依赖性冲突?

1 个答案:

答案 0 :(得分:0)

将Gradle插件更新为

classpath 'com.android.tools.build:gradle:2.3.3'

将gradle compile sdk版本,buildtool版本和目标sdk版本更改为更新版本。

样本,

compileSdkVersion 25
buildToolsVersion "25.0.3"
targetSdkVersion 25

并将gradle依赖项更改为相同版本的builtoolversion

compile 'com.android.support:support-compat:25.3.1'
compile 'com.android.support:support-media-compat:25.3.1'
compile 'com.android.support:support-core-ui:25.3.1'
compile 'com.android.support:support-fragment:25.3.1'
compile 'com.android.support:support-core-utils:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:support-annotations:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.google.dagger:dagger:2.0.2'
compile 'com.google.dagger:dagger-compiler:2.0.2'

您必须使用匕首依赖

compile 'com.google.dagger:dagger:2.0.2'
compile 'com.google.dagger:dagger-compiler:2.0.2'

而不是

com.google.dagger:dagger-android:2.9
com.google.dagger:dagger:2.9