我升级到了Android Studio 3和Gradle 4,并在我的build.gradle文件中将compile
改为implementation
,但是我遇到了错误:
Error:Execution failed for task ':app:preDebugBuild'.
> Android dependency 'com.google.firebase:firebase-core' has different version for the compile (9.0.0) and runtime (11.6.0) classpath. You should manually set the same version via DependencyResolution
当我将implementation
更改为api
时,错误消失了。但这不是解决方案。我有一个应用程序模块和一个库模块。应用程序build.gradle只有一个依赖项。implementation project(':common-lib')
apply plugin: 'com.google.gms.google-services'
已经正确地放置在 app build.gradle 文件的末尾(在迁移到 Gradle 4 之前该项目已经可以正常工作)
从 gradlew app:dependencies 中获取的依赖关系(文本片段):
编译
debugAndroidTestCompileClasspath - Resolved configuration for compilation for variant: debugAndroidTest
+--- com.google.firebase:firebase-core:9.0.0
| \--- com.google.firebase:firebase-analytics:9.0.0
| +--- com.google.android.gms:play-services-basement:9.0.0
| | \--- com.android.support:support-v4:23.0.0
| | \--- com.android.support:support-annotations:23.0.0
| +--- com.google.firebase:firebase-common:9.0.0
| | +--- com.google.android.gms:play-services-basement:9.0.0 (*)
| | \--- com.google.android.gms:play-services-tasks:9.0.0
| | \--- com.google.android.gms:play-services-basement:9.0.0 (*)
| \--- com.google.firebase:firebase-analytics-impl:9.0.0
| +--- com.google.android.gms:play-services-base:9.0.0
| | +--- com.google.android.gms:play-services-basement:9.0.0 (*)
| | +--- com.google.firebase:firebase-common:9.0.0 (*)
| | \--- com.google.android.gms:play-services-tasks:9.0.0 (*)
| +--- com.google.android.gms:play-services-basement:9.0.0 (*)
| +--- com.google.firebase:firebase-iid:9.0.0
| | +--- com.google.android.gms:play-services-basement:9.0.0 (*)
| | \--- com.google.firebase:firebase-common:9.0.0 (*)
| \--- com.google.firebase:firebase-common:9.0.0 (*)
\--- project :common-lib
(............)
运行时
debugAndroidTestRuntimeClasspath - Resolved configuration for runtime for variant: debugAndroidTest
+--- com.google.firebase:firebase-core:9.0.0 -> 11.6.0
| \--- com.google.firebase:firebase-analytics:11.6.0
| +--- com.google.android.gms:play-services-basement:11.6.0
| | +--- com.android.support:support-v4:25.2.0 -> 26.1.0
| | | +--- com.android.support:support-compat:26.1.0
| | | | +--- com.android.support:support-annotations:26.1.0
| | | | \--- android.arch.lifecycle:runtime:1.0.0
| | | | +--- android.arch.lifecycle:common:1.0.0
| | | | \--- android.arch.core:common:1.0.0
| | | +--- com.android.support:support-media-compat:26.1.0
| | | | +--- com.android.support:support-annotations:26.1.0
| | | | \--- com.android.support:support-compat:26.1.0 (*)
| | | +--- com.android.support:support-core-utils:26.1.0
| | | | +--- com.android.support:support-annotations:26.1.0
| | | | \--- com.android.support:support-compat:26.1.0 (*)
| | | +--- com.android.support:support-core-ui:26.1.0
| | | | +--- com.android.support:support-annotations:26.1.0
| | | | \--- com.android.support:support-compat:26.1.0 (*)
| | | \--- com.android.support:support-fragment:26.1.0
| | | +--- com.android.support:support-compat:26.1.0 (*)
| | | +--- com.android.support:support-core-ui:26.1.0 (*)
| | | \--- com.android.support:support-core-utils:26.1.0 (*)
| | \--- com.google.android.gms:play-services-basement-license:11.6.0
| +--- com.google.firebase:firebase-common:11.6.0
| | +--- com.google.android.gms:play-services-basement:11.6.0 (*)
| | +--- com.google.android.gms:play-services-tasks:11.6.0
| | | +--- com.google.android.gms:play-services-basement:11.6.0 (*)
| | | \--- com.google.android.gms:play-services-tasks-license:11.6.0
| | \--- com.google.firebase:firebase-common-license:11.6.0
| +--- com.google.firebase:firebase-analytics-impl:11.6.0
| | +--- com.google.android.gms:play-services-basement:11.6.0 (*)
| | +--- com.google.firebase:firebase-iid:11.6.0
| | | +--- com.google.android.gms:play-services-basement:11.6.0 (*)
| | | +--- com.google.firebase:firebase-common:11.6.0 (*)
| | | +--- com.google.android.gms:play-services-tasks:11.6.0 (*)
| | | \--- com.google.firebase:firebase-iid-license:11.6.0
| | +--- com.google.firebase:firebase-common:11.6.0 (*)
| | +--- com.google.android.gms:play-services-tasks:11.6.0 (*)
| | \--- com.google.firebase:firebase-analytics-impl-license:11.6.0
| \--- com.google.firebase:firebase-analytics-license:11.6.0
\--- project :common-lib
(.............)
已编辑:
应用程序依赖项
dependencies {
implementation project(':common-lib')
}
常用库依赖
dependencies {
//android firebase
implementation "com.google.firebase:firebase-core:$firebase_version"
implementation "com.google.firebase:firebase-crash:$firebase_version"
implementation "com.google.firebase:firebase-messaging:$firebase_version"
implementation "com.google.firebase:firebase-ads:$firebase_version"
//android support
implementation "com.android.support:appcompat-v7:$support_version"
implementation "com.android.support:design:$support_version"
implementation "com.android.support:cardview-v7:$support_version"
implementation "com.android.support:percent:$support_version"
//others
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.hannesdorfmann:adapterdelegates3:3.0.1'
implementation 'net.danlew:android.joda:2.9.9'
implementation 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.github.simbiose:Encryption:2.0.1'
//server
implementation files('libs/xxx.jar')
implementation files('libs/yyy.jar')
implementation files('libs/zzz.jar')
//tests
testImplementation 'junit:junit:4.12'
}
版本:
ext {
firebase_version = '11.6.0'
support_version = '26.1.0'
}
com.google.firebase:firebase
库吗? - user6490462