解决'androidx.arch.core:core-runtime' has different version for the compile (2.0.0) and runtime (2.0.1)

摘要:
先说原因,我们引用的包版本不同产生了冲突,所以编译不通过。

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

解决过程:

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

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 forvariant: 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'}
}

免责声明:文章转载自《解决'androidx.arch.core:core-runtime' has different version for the compile (2.0.0) and runtime (2.0.1)》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇zabbix添加触发器TriggersSpark聚合操作:combineByKey()下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

使用cmd命令行(.NET Core CLI)来启动ASP.NET Core 应用程序的多个实例

本章主要和大家分享下如何使用cmd命令行(.NET Core CLI)来启动ASP.NET Core 应用程序的多个实例,以此来模拟集群。 .NET Core 命令行接口 (CLI) 工具是用于开发、生成、运行和发布 .NET Core 应用程序的跨平台工具链。 CLI 命令结构包含驱动程序(“dotnet”)和命令,还可能包含命令参数和选项。 话不多说,...

ASP.NET CORE中使用Cookie身份认证

大家在使用ASP.NET的时候一定都用过FormsAuthentication做登录用户的身份认证,FormsAuthentication的核心就是Cookie,ASP.NET会将用户名存储在Cookie中。 现在到了ASP.NET CORE的时代,但是ASP.NET CORE中没有FormsAuthentication这个东西,那么怎么做身份认证呢?答案...

ASP.NET Core开发者路线指南(转)

先决条件 C# Entity Framework ASP.NET Core SQL基础知识 通用开发技能 学习GIT, 在GitHub中创建开源项目 掌握HTTP(S)协议, 及其请求方法(GET, POST, PUT, PATCH, DELETE, OPTIONS) 不要害怕使用 Google,Google搜索技巧 学习dotnet CL...

利用pyinstaller打包加密Python项目

  最近用Python给媳妇写了两个小项目,给解决了她的每天重复的一些人工操作。媳妇很开心,但是问题来了,她是个Python小白,对她来说,需要安装配置Python环境和一大堆第三方模块是个麻烦事儿。而且后续把这些工作交接给别人的话,一是又需要重新安装Python环境,二是我辛苦给她写的源码就这样暴露了。   为了解决这个问题,于是就开始百度。果然Pyth...

thinkphp第1课:使用thinkphp创建一个项目

一、thinkphp第一课:1、在网站根目录下,建立一个项目名称orange;2、在orange目录下,创建一个入口文件index.php:<?phpdefine('APP_DEBUG',true); //开启调试模式require('../TP/ThinkPHP.php');?> 3、下载thinkphp核心包并解压,放在网站根目录下(与or...

opencv linux

http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html https://www.google.com.hk/search?q=opencv+linux&ie=utf-8&oe=utf-8&gws_rd=cr&ei=f...