我们在app的build.gradle文件看见一个报错。
原因是我们设置了v7的版本com.android.support:appcompat-v7:26.1.0
,但是我们在引用第三方库的时候出现了报错。大致的意思就是我们使用的v7的库和我们的recyclerview的搭配版本不相同,这会使我们的版本不兼容。
为了进一步验证,我们使用了gradle app:dependencies | log.txt
命令,对项目的编译时间和运行时间的依赖库进行查看。
releaseRuntimeClasspath - Resolved configuration for runtime for variant: release
+--- com.android.support:appcompat-v7:26.1.0
| +--- com.android.support:support-annotations:26.1.0
| +--- com.android.support:support-v4:26.1.0
| | +--- com.android.support:support-compat:26.1.0
| | | +--- com.android.support:support-annotations:26.1.0
| | | \--- android.arch.lifecycle:runtime:1.0.0
| | | +--- android.arch.lifecycle:common:1.0.0
| | | \--- android.arch.core:common:1.0.0
| | +--- com.android.support:support-media-compat:26.1.0
| | | +--- com.android.support:support-annotations:26.1.0
| | | \--- com.android.support:support-compat:26.1.0 (*)
| | +--- com.android.support:support-core-utils:26.1.0
| | | +--- com.android.support:support-annotations:26.1.0
| | | \--- com.android.support:support-compat:26.1.0 (*)
| | +--- com.android.support:support-core-ui:26.1.0
| | | +--- com.android.support:support-annotations:26.1.0
| | | \--- com.android.support:support-compat:26.1.0 (*)
| | \--- com.android.support:support-fragment:26.1.0
| | +--- com.android.support:support-compat:26.1.0 (*)
| | +--- com.android.support:support-core-ui:26.1.0 (*)
| | \--- com.android.support:support-core-utils:26.1.0 (*)
| +--- com.android.support:support-vector-drawable:26.1.0
| | +--- com.android.support:support-annotations:26.1.0
| | \--- com.android.support:support-compat:26.1.0 (*)
| \--- com.android.support:animated-vector-drawable:26.1.0
| +--- com.android.support:support-vector-drawable:26.1.0 (*)
| \--- com.android.support:support-core-ui:26.1.0 (*)
+--- com.android.support.constraint:constraint-layout:1.1.2
| \--- com.android.support.constraint:constraint-layout-solver:1.1.2
+--- com.commit451:PhotoView:1.2.4
| \--- com.android.support:support-v4:23.0.1 -> 26.1.0 (*)
+--- jp.wasabeef:glide-transformations:2.0.1
| \--- com.github.bumptech.glide:glide:3.7.0
+--- cn.bingoogolapple:bga-refreshlayout:1.1.6
| +--- com.nineoldandroids:library:2.4.0
| \--- com.android.support:recyclerview-v7:24.0.0
| +--- com.android.support:support-annotations:24.0.0 -> 26.1.0
| \--- com.android.support:support-v4:24.0.0 -> 26.1.0 (*)
+--- com.jakewharton:butterknife:7.0.1
+--- io.reactivex:rxjava:1.2.1 -> 1.3.0
+--- io.reactivex:rxandroid:1.2.1
| \--- io.reactivex:rxjava:1.1.6 -> 1.3.0
+--- com.squareup.okio:okio:1.13.0
+--- com.squareup.retrofit2:retrofit:2.3.0
| \--- com.squareup.okhttp3:okhttp:3.8.0 -> 3.9.0
| \--- com.squareup.okio:okio:1.13.0
+--- com.squareup.retrofit2:converter-scalars:2.3.0
| \--- com.squareup.retrofit2:retrofit:2.3.0 (*)
+--- com.squareup.retrofit2:converter-gson:2.3.0
| +--- com.squareup.retrofit2:retrofit:2.3.0 (*)
| \--- com.google.code.gson:gson:2.7
+--- com.squareup.retrofit2:adapter-rxjava:2.3.0
| +--- com.squareup.retrofit2:retrofit:2.3.0 (*)
| \--- io.reactivex:rxjava:1.3.0
+--- com.squareup.okhttp3:okhttp:3.9.0 (*)
+--- com.squareup.okhttp3:logging-interceptor:3.9.0
| \--- com.squareup.okhttp3:okhttp:3.9.0 (*)
+--- org.greenrobot:greendao:3.2.2
| \--- org.greenrobot:greendao-api:3.2.2
+--- com.android.support:multidex:1.0.0
+--- com.tbruyelle.rxpermissions:rxpermissions:0.7.1
\--- com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+ -> 5.1.4
上面的标识代表着不同的含义,我来解释下:
*
号表示,gradle使用了相同版本或者另一个版本来作为依赖。->
号,表示gradle将使用符号后面的版本作为依赖。+--- com.android.support:appcompat-v7:26.1.0
| +--- com.android.support:support-annotations:26.1.0
| +--- com.android.support:support-v4:26.1.0
| | +--- com.android.support:support-compat:26.1.0
| | | +--- com.android.support:support-annotations:26.1.0
| | | \--- android.arch.lifecycle:runtime:1.0.0
| | | +--- android.arch.lifecycle:common:1.0.0
| | | \--- android.arch.core:common:1.0.0
| | +--- com.android.support:support-media-compat:26.1.0
| | | +--- com.android.support:support-annotations:26.1.0
| | | \--- com.android.support:support-compat:26.1.0 (*)
| | +--- com.android.support:support-core-utils:26.1.0
| | | +--- com.android.support:support-annotations:26.1.0
| | | \--- com.android.support:support-compat:26.1.0 (*)
| | +--- com.android.support:support-core-ui:26.1.0
| | | +--- com.android.support:support-annotations:26.1.0
| | | \--- com.android.support:support-compat:26.1.0 (*)
| | \--- com.android.support:support-fragment:26.1.0
| | +--- com.android.support:support-compat:26.1.0 (*)
| | +--- com.android.support:support-core-ui:26.1.0 (*)
| | \--- com.android.support:support-core-utils:26.1.0 (*)
| +--- com.android.support:support-vector-drawable:26.1.0
| | +--- com.android.support:support-annotations:26.1.0
| | \--- com.android.support:support-compat:26.1.0 (*)
| \--- com.android.support:animated-vector-drawable:26.1.0
| +--- com.android.support:support-vector-drawable:26.1.0 (*)
| \--- com.android.support:support-core-ui:26.1.0 (*)
...
+--- cn.bingoogolapple:bga-refreshlayout:1.1.6
| +--- com.nineoldandroids:library:2.4.0
| \--- com.android.support:recyclerview-v7:24.0.0
| +--- com.android.support:support-annotations:24.0.0 -> 26.1.0
| \--- com.android.support:support-v4:24.0.0 -> 26.1.0 (*)
可以看见,我们的bga-refreshlayout
使用的recyclerview
还是24.0.0
,这就导致了我们的recyclerview
的版本和当前的v7
版本不兼容。
除bga-refreshlayout
外,其余类库均统一版本库recyclerview
的版本库。
recyclerview
版本。 implementation rootProject.ext.dependencies["recyclerview-v7"]
这里加入这段代码,项目中所有的引用库都会统一引用recyclerview
。
bga-refreshlayout
使用自己的版本库。implementation(rootProject.ext.dependencies["refreshlayout"]) {
exclude group: 'com.android.support'
}
releaseRuntimeClasspath - Resolved configuration for runtime for variant: release
+--- com.android.support:appcompat-v7:26.1.0
| +--- com.android.support:support-annotations:26.1.0
| +--- com.android.support:support-v4:26.1.0
| | +--- com.android.support:support-compat:26.1.0
| | | +--- com.android.support:support-annotations:26.1.0
| | | \--- android.arch.lifecycle:runtime:1.0.0
| | | +--- android.arch.lifecycle:common:1.0.0
| | | \--- android.arch.core:common:1.0.0
| | +--- com.android.support:support-media-compat:26.1.0
| | | +--- com.android.support:support-annotations:26.1.0
| | | \--- com.android.support:support-compat:26.1.0 (*)
| | +--- com.android.support:support-core-utils:26.1.0
| | | +--- com.android.support:support-annotations:26.1.0
| | | \--- com.android.support:support-compat:26.1.0 (*)
| | +--- com.android.support:support-core-ui:26.1.0
| | | +--- com.android.support:support-annotations:26.1.0
| | | \--- com.android.support:support-compat:26.1.0 (*)
| | \--- com.android.support:support-fragment:26.1.0
| | +--- com.android.support:support-compat:26.1.0 (*)
| | +--- com.android.support:support-core-ui:26.1.0 (*)
| | \--- com.android.support:support-core-utils:26.1.0 (*)
| +--- com.android.support:support-vector-drawable:26.1.0
| | +--- com.android.support:support-annotations:26.1.0
| | \--- com.android.support:support-compat:26.1.0 (*)
| \--- com.android.support:animated-vector-drawable:26.1.0
| +--- com.android.support:support-vector-drawable:26.1.0 (*)
| \--- com.android.support:support-core-ui:26.1.0 (*)
+--- com.android.support:support-v4:26.1.0 (*)
+--- com.android.support.constraint:constraint-layout:1.1.2
| \--- com.android.support.constraint:constraint-layout-solver:1.1.2
+--- com.android.support:recyclerview-v7:26.1.0
| +--- com.android.support:support-annotations:26.1.0
| +--- com.android.support:support-compat:26.1.0 (*)
| \--- com.android.support:support-core-ui:26.1.0 (*)
+--- com.commit451:PhotoView:1.2.4
| \--- com.android.support:support-v4:23.0.1 -> 26.1.0 (*)
+--- jp.wasabeef:glide-transformations:2.0.1
| \--- com.github.bumptech.glide:glide:3.7.0
+--- cn.bingoogolapple:bga-refreshlayout:1.1.6
| \--- com.nineoldandroids:library:2.4.0
+--- com.jakewharton:butterknife:7.0.1
+--- io.reactivex:rxjava:1.2.1 -> 1.3.0
+--- io.reactivex:rxandroid:1.2.1
| \--- io.reactivex:rxjava:1.1.6 -> 1.3.0
+--- com.squareup.okio:okio:1.13.0
+--- com.squareup.retrofit2:retrofit:2.3.0
| \--- com.squareup.okhttp3:okhttp:3.8.0 -> 3.9.0
| \--- com.squareup.okio:okio:1.13.0
+--- com.squareup.retrofit2:converter-scalars:2.3.0
| \--- com.squareup.retrofit2:retrofit:2.3.0 (*)
+--- com.squareup.retrofit2:converter-gson:2.3.0
| +--- com.squareup.retrofit2:retrofit:2.3.0 (*)
| \--- com.google.code.gson:gson:2.7
+--- com.squareup.retrofit2:adapter-rxjava:2.3.0
| +--- com.squareup.retrofit2:retrofit:2.3.0 (*)
| \--- io.reactivex:rxjava:1.3.0
+--- com.squareup.okhttp3:okhttp:3.9.0 (*)
+--- com.squareup.okhttp3:logging-interceptor:3.9.0
| \--- com.squareup.okhttp3:okhttp:3.9.0 (*)
+--- org.greenrobot:greendao:3.2.2
| \--- org.greenrobot:greendao-api:3.2.2
+--- com.android.support:multidex:1.0.0
+--- com.tbruyelle.rxpermissions:rxpermissions:0.7.1
\--- com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+ -> 5.1.4
看上面的依赖,问题得以解决。