【发布时间】:2023-03-12 22:15:01
【问题描述】:
今天我在 android studio 开始了一个新项目。一切顺利,没有错误。添加项目后,我借助android studio中的Firebase助手工具将项目与Firebase实时数据库连接起来。
然后我得到这个错误:
Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
> Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (23.0.0) and test app (25.4.0) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.
我看到错误主要来自在我的应用程序级别 build.gradle 文件的末尾添加这一行。因为当我将其注释掉时,它构建得很好。
apply plugin: 'com.google.gms.google-services'
我对 gradle 构建系统了解不多。仅连接到 firebase 并添加 firebase-database 依赖项可能有什么问题。
我需要检查的资源
我的应用程序:build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.learning.insanes.chothavandar"
minSdkVersion 21
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(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
// implementation 'com.google.firebase:firebase-database:11.6.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
我的项目:build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
【问题讨论】:
标签: android firebase android-gradle-plugin google-play-services build.gradle