android - build.gradle:为 sdk 版本 27 添加播放服务依赖项时出错
问题描述
添加依赖 项实现 'com.google.android.gms:play-services-location:15.0.1'后,我在依赖项实现 'com.android.support:appcompat-v7:27.1.1'上遇到错误
所有 com.android.support 库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本 27.1.1、26.1.0。例子包括 com.android.support:animated-vector-drawable:27.1.1 和 com.android.support:support-media-compat:26.1.0 less... (Ctrl+F1) 有一些库的组合,或者不兼容或可能导致错误的工具和库。一种这样的不兼容是使用不是最新版本的 Android 支持库版本(或者特别是低于您的 targetSdkVersion 的版本)进行编译
我想使用需要位置依赖性的“PlaceAutocompleteFragment”。我尝试使用以下方法添加位置依赖项:
文件 > 项目结构 > 依赖项 > + > 搜索位置
获得了位置版本 12.0.2,仍然抛出上述错误。我知道还有其他问题有相同的错误,但我仍然无法找出我的错误的解决方案。
构建.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.manish.abc"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
另外请让我知道如何找到适用于我正在使用的 api 级别的正确版本的依赖项。
解决方案
更新:
在提示中你有:
所有 com.android.support 库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本27.1.1, 26.1.0。例子包括 com.android.support:animated-vector-drawable:27.1.1 和 com.android.support:support-media-compat:26.1.0 less... (Ctrl+F1) 有一些库的组合,或者不兼容或可能导致错误的工具和库。一种这样的不兼容是使用不是最新版本的 Android 支持库版本(或者特别是低于您的 targetSdkVersion 的版本)进行编译
您必须使用提示中显示的较低版本覆盖每个库,使用较高版本,例如com.android.support:support-media-compat:26.1.0
(在提示中看到)
添加'com.android.support:support-media-compat:27.1.1'
更高版本27.1.1而不是26.1.0:
implementation 'com.android.support:support-media-compat:27.1.1'
然后你重复这个直到警告消失
推荐阅读
- python - 为 docker 容器选择哪个端口号
- racket - 基于 2 个数字和 1 个运算符执行算术运算
- typescript - 打字稿库不受尊重
- r - R Shiny:运行应用程序本地与部署时导出的 PNG 分辨率不同
- apache-kafka-streams - RocksDB NoClassDefFound - 如何为 Kafka 流设置 RocksDB
- reactjs - 类扩展值 undefined 不是构造函数或 null
- regex - 匹配时隙的正则表达式
- html - 将容器定位在页面底部
- opencv - cv2.imread() 随机使图像变为“无”
- python - 随着时间的推移将多维多索引数据帧与单索引数据帧相乘