加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

解决'androidx.arch.core:core-runtime' has diff

发布时间:2020-12-14 00:39:30 所属栏目:Linux 来源:网络整理
导读:先说原因,我们引用的包版本不同产生了冲突,所以编译不通过。解决的办法是在引用的时候排除一个版本,只留一个版本。 解决过程: 先找出哪些库引用了相同的库,仅仅是版本不同。 gradle app:dependencies app换成你工程中的模块名,它会生成一个依赖列表,

先说原因,我们引用的包版本不同产生了冲突,所以编译不通过。解决的办法是在引用的时候排除一个版本,只留一个版本。

解决过程:

先找出哪些库引用了相同的库,仅仅是版本不同。

gradle app:dependencies

app换成你工程中的模块名,它会生成一个依赖列表,我们要做的是分析一下这个列表,比如我的引用就是:

dependencies {
    implementation fileTree(dir: libs,include: [*.jar])

    implementation androidx.appcompat:appcompat:1.1.0
    implementation androidx.constraintlayout:constraintlayout:1.1.3
    implementation com.google.android.material:material:1.0.0
    implementation androidx.lifecycle:lifecycle-process:2.2.0-alpha04
    implementation androidx.work:work-runtime:2.3.0-alpha01
}

?


在编译的时候就产生了‘androidx.arch.core:core-runtime‘ has different version for the compile (2.0.0) and runtime (2.0.1)错误
我这个模块叫work,所以通过gradle work:dependencies得到一个列表:
releaseUnitTestRuntimeClasspath - Resolved configuration for runtime for variant: releaseUnitTest
+--- androidx.appcompat:appcompat:1.1.0
|    +--- androidx.annotation:annotation:1.1.0
|    +--- androidx.core:core:1.1.0
|    |    +--- androidx.annotation:annotation:1.1.0
|    |    +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.2.0-alpha04
|    |    |    +--- androidx.lifecycle:lifecycle-common:2.2.0-alpha04
|    |    |    |    --- androidx.annotation:annotation:1.1.0
|    |    |    +--- androidx.arch.core:core-common:2.1.0-rc01
|    |    |    |    --- androidx.annotation:annotation:1.1.0
|    |    |    --- androidx.annotation:annotation:1.1.0
|    |    +--- androidx.versionedparcelable:versionedparcelable:1.1.0
|    |    |    +--- androidx.annotation:annotation:1.1.0
|    |    |    --- androidx.collection:collection:1.0.0 -> 1.1.0
|    |    |         --- androidx.annotation:annotation:1.1.0
|    |    --- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    +--- androidx.cursoradapter:cursoradapter:1.0.0
|    |    --- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    +--- androidx.fragment:fragment:1.1.0
|    |    +--- androidx.annotation:annotation:1.1.0
|    |    +--- androidx.core:core:1.1.0 (*)
|    |    +--- androidx.collection:collection:1.1.0 (*)
|    |    +--- androidx.viewpager:viewpager:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    |    +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
|    |    |    --- androidx.customview:customview:1.0.0
|    |    |         +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    |         --- androidx.core:core:1.0.0 -> 1.1.0 (*)
|    |    +--- androidx.loader:loader:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    |    +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
|    |    |    +--- androidx.lifecycle:lifecycle-livedata:2.0.0
|    |    |    |    +--- androidx.arch.core:core-runtime:2.0.0 -> 2.0.1
|    |    |    |    |    +--- androidx.annotation:annotation:1.0.2 -> 1.1.0
|    |    |    |    |    --- androidx.arch.core:core-common:2.0.1 -> 2.1.0-rc01 (*)
|    |    |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.0.0
|    |    |    |    |    +--- androidx.lifecycle:lifecycle-common:2.0.0 -> 2.2.0-alpha04 (*)
|    |    |    |    |    +--- androidx.arch.core:core-common:2.0.0 -> 2.1.0-rc01 (*)
|    |    |    |    |    --- androidx.arch.core:core-runtime:2.0.0 -> 2.0.1 (*)
|    |    |    |    --- androidx.arch.core:core-common:2.0.0 -> 2.1.0-rc01 (*)
|    |    |    --- androidx.lifecycle:lifecycle-viewmodel:2.0.0 -> 2.1.0
|    |    |         --- androidx.annotation:annotation:1.1.0
|    |    +--- androidx.activity:activity:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.1.0
|    |    |    +--- androidx.core:core:1.1.0 (*)
|    |    |    +--- androidx.lifecycle:lifecycle-runtime:2.1.0 -> 2.2.0-alpha04 (*)
|    |    |    +--- androidx.lifecycle:lifecycle-viewmodel:2.1.0 (*)
|    |    |    --- androidx.savedstate:savedstate:1.0.0
|    |    |         +--- androidx.annotation:annotation:1.1.0
|    |    |         +--- androidx.arch.core:core-common:2.0.1 -> 2.1.0-rc01 (*)
|    |    |         --- androidx.lifecycle:lifecycle-common:2.0.0 -> 2.2.0-alpha04 (*)
|    |    --- androidx.lifecycle:lifecycle-viewmodel:2.0.0 -> 2.1.0 (*)
|    +--- androidx.appcompat:appcompat-resources:1.1.0
|    |    +--- androidx.annotation:annotation:1.1.0
|    |    +--- androidx.core:core:1.0.1 -> 1.1.0 (*)
|    |    +--- androidx.vectordrawable:vectordrawable:1.1.0
|    |    |    +--- androidx.annotation:annotation:1.1.0
|    |    |    +--- androidx.core:core:1.1.0 (*)
|    |    |    --- androidx.collection:collection:1.1.0 (*)
|    |    +--- androidx.vectordrawable:vectordrawable-animated:1.1.0
|    |    |    +--- androidx.vectordrawable:vectordrawable:1.1.0 (*)
|    |    |    +--- androidx.interpolator:interpolator:1.0.0
|    |    |    |    --- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    |    --- androidx.collection:collection:1.1.0 (*)
|    |    --- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    +--- androidx.drawerlayout:drawerlayout:1.0.0
|    |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
|    |    --- androidx.customview:customview:1.0.0 (*)
|    --- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
+--- androidx.constraintlayout:constraintlayout:1.1.3
|    --- androidx.constraintlayout:constraintlayout-solver:1.1.3
+--- com.google.android.material:material:1.0.0
|    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
|    +--- androidx.legacy:legacy-support-core-ui:1.0.0
|    |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
|    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    |    +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
|    |    |    +--- androidx.documentfile:documentfile:1.0.0
|    |    |    |    --- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    |    +--- androidx.loader:loader:1.0.0 (*)
|    |    |    +--- androidx.localbroadcastmanager:localbroadcastmanager:1.0.0
|    |    |    |    --- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    |    --- androidx.print:print:1.0.0
|    |    |         --- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    +--- androidx.customview:customview:1.0.0 (*)
|    |    +--- androidx.viewpager:viewpager:1.0.0 (*)
|    |    +--- androidx.coordinatorlayout:coordinatorlayout:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    |    +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
|    |    |    --- androidx.customview:customview:1.0.0 (*)
|    |    +--- androidx.drawerlayout:drawerlayout:1.0.0 (*)
|    |    +--- androidx.slidingpanelayout:slidingpanelayout:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    |    +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
|    |    |    --- androidx.customview:customview:1.0.0 (*)
|    |    +--- androidx.interpolator:interpolator:1.0.0 (*)
|    |    +--- androidx.swiperefreshlayout:swiperefreshlayout:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    |    +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
|    |    |    --- androidx.interpolator:interpolator:1.0.0 (*)
|    |    +--- androidx.asynclayoutinflater:asynclayoutinflater:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    |    --- androidx.core:core:1.0.0 -> 1.1.0 (*)
|    |    --- androidx.cursoradapter:cursoradapter:1.0.0 (*)
|    +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
|    +--- androidx.fragment:fragment:1.0.0 -> 1.1.0 (*)
|    +--- androidx.transition:transition:1.0.0
|    |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    --- androidx.core:core:1.0.0 -> 1.1.0 (*)
|    +--- androidx.appcompat:appcompat:1.0.0 -> 1.1.0 (*)
|    +--- androidx.cardview:cardview:1.0.0
|    |    --- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    --- androidx.recyclerview:recyclerview:1.0.0
|         +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|         +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
|         --- androidx.legacy:legacy-support-core-ui:1.0.0 (*)
+--- androidx.lifecycle:lifecycle-process:2.2.0-alpha04
|    --- androidx.lifecycle:lifecycle-runtime:2.2.0-alpha04 (*)
--- androidx.work:work-runtime:2.3.0-alpha01
     +--- com.google.guava:listenablefuture:1.0
     +--- androidx.lifecycle:lifecycle-livedata:2.0.0 (*)
     +--- androidx.room:room-runtime:2.1.0
     |    +--- androidx.room:room-common:2.1.0
     |    |    --- androidx.annotation:annotation:1.1.0
     |    +--- androidx.sqlite:sqlite-framework:2.0.1
     |    |    +--- androidx.annotation:annotation:1.0.2 -> 1.1.0
     |    |    --- androidx.sqlite:sqlite:2.0.1
     |    |         --- androidx.annotation:annotation:1.0.2 -> 1.1.0
     |    +--- androidx.sqlite:sqlite:2.0.1 (*)
     |    +--- androidx.arch.core:core-runtime:2.0.1 (*) |    +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
     |    --- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
     +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
     --- androidx.lifecycle:lifecycle-service:2.0.0
          --- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.2.0-alpha04 (*)

然后我们沿着树形结构可以找到,androidx.work:work-runtime:2.3.0-alpha01和?androidx.appcompat:appcompat:1.1.0中的core-runtime版本冲突了,解决的办法是去掉一个留一个,我是把work-runtime中的去掉了。如下:

dependencies {
    implementation fileTree(dir: libs,include: [*.jar])

    implementation androidx.appcompat:appcompat:1.1.0
    implementation androidx.constraintlayout:constraintlayout:1.1.3
    implementation com.google.android.material:material:1.0.0
    implementation androidx.lifecycle:lifecycle-process:2.2.0-alpha04
    implementation (androidx.work:work-runtime:2.3.0-alpha01){
        exclude group: androidx.arch.core
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读