android - android gradle 错误:库必须使用完全相同的版本规范。找到版本 28.0.0
问题描述
这是应用程序级别的依赖项。我一直在尝试将 firebase 添加到我的应用程序中。但它显示错误
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.rachitshah.fireapp"
minSdkVersion 15
targetSdkVersion 28
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(dir: 'libs', include: ['*.jar'])
这一行的错误
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
这是firebase依赖。
implementation 'com.google.firebase:firebase-core:16.0.1'
解决方案
当您通过添加在 gradle 文件中添加 firebase 依赖项时
implementation 'com.google.firebase:firebase-core:16.0.1'
然后在您的应用中也添加了 2 个库
com.android.support:support-media-compat:26.1.0
com.android.support:support-v4:26.1.0
他们的版本与 versin 28.0.0 不同,这是错误发生的原因。
要修复此错误,请更改您的 gradle 文件
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
// Add this line
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
implementation 'com.google.firebase:firebase-core:16.0.1'
}
推荐阅读
- excel - 需要一种使用 Excel VBA 在特定单元格中输入数据的方法
- python - 无论如何要在python的新列表中获取列表的随机索引
- parsing - 两个 Haskell 程序如何通过 stdin 和 stdout 交换整数值而不将数据视为文本?
- asp.net-core-mvc - ASP.NET Core MVC 的生产数据库创建/迁移困境
- javascript - 为什么我的函数未定义且未加载
- grpc - 我们如何在同一个流中继续与助手通信?
- typescript - 展平嵌套元组类型并保留顺序
- ruby-on-rails - 手动定义的方法有效,但 define_method 无效,没有给出错误
- c++ - 改变输出的变量
- python - AttributeError: 'float' 对象没有属性 'upper'