android - 支持库版本问题
问题描述
我在升级我的应用程序时遇到了困难。我在 build.gradle 文件(应用程序)的一行中收到此错误(红色下划线)
implementation 'com.android.support:appcompat-v7:28.0.0'
当我将鼠标悬停在这条线上时的消息:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:support-media-compat:26.1.0 less... (Ctrl+F1)
Inspection info:There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).
我的应用 build.gradle 如下所示:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.theaskdev.sitmangalore"
minSdkVersion 21
targetSdkVersion 28
versionCode 17
multiDexEnabled true
versionName "5.7"
ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
signingConfig signingConfigs.release
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation "com.android.support:support-compat:28.0.0"
implementation "com.android.support:support-core-utils:28.0.0"
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-crash:16.2.1'
implementation 'com.google.firebase:firebase-core:16.0.7'
}
apply plugin: 'com.google.gms.google-services'
我的项目 build.gradle 如下:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
请有人解释如何解决此版本问题。这是我的严重困惑之一。我已经检查了建议的答案。但这并没有解决我的问题。
解决方案
app\build.gradle
在你的文件中试试这个:
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.android.support') {
details.useVersion "28.0.0"
} else if (details.requested.group == 'com.google.firebase') {
details.useVersion "16.2.1"
}
}
}
您还应该使用gradle-versions-plugin来获取最新版本的依赖项。
推荐阅读
- ios - 删除一个后重新定位其他 UIButton
- javascript - 我们如何使用 javascript 从 HTML 画布创建适当的矢量 SVG 文件?
- reactjs - 将容器组件嵌套在表示组件中是否被认为是一种不好的做法?
- javascript - 我如何在反应 js 的 nextjs 中访问 _app.js 文件中的上下文
- kentico - 无法使用导入工具包将文件导入页面
- webpack - date-fns - 使用 webpack 配置从捆绑包中排除语言环境
- javascript - 表单未按 ajax 请求提交
- python - Dash App 回调在数据框中追加新条目,如果与任何先前条目匹配则替换
- python - 填充 numpy 数组并绘制图表的最佳方法是什么?
- jquery - 如何将两个数组作为 POST 请求参数从 AJAX 发送到 MVC 控制器(ASP .NET Core 3.1 剃须刀)?