Я перешел на Android Studio 3 и Gradle 4. Затем я изменил compile
на implementation
в моих файлах build.gradle. Но я получаю сообщение об ошибке:
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'
правильно помещается в нижней части файла build.gradle приложения (проект работал до перехода на Gradle 4)
Зависимости от приложения gradlew: зависимости (обрезка текста):
Вкомпилировать
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')
}
общие зависимости 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'
}