問題描述
嘗試使用 FireStore 和 Google 身份驗證創建一個簡單的應用程序.gradle 有問題:
Trying to create a simple app with FireStore and Google Authentication. Having problem with the gradle:
在項目app"中,解決了 Google Play 服務庫依賴項取決于另一個確切版本(例如[15.0.1]",但不是正在解決該版本.圖書館展示的行為將不為人知.
In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[15.0. 1]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.
依賴失敗:com.google.android.gms:play-services-flags:15.0.1-> com.google.android.gms:play-services-basement@[15.0.1],但 play-services-basement 版本是 16.0.1.
Dependency failing: com.google.android.gms:play-services-flags:15.0.1 -> com.google.android.gms:play-services-basement@[ 15.0.1], but play-services-basement version was 16.0.1.
以下依賴項是直接或直接的項目依賴項具有傳遞依賴關系,導致藝術 ifact 與問題.-- 項目 'app' 依賴于 com.google.firebase:firebase-firestore@17.1.5-- 項目 'app' 依賴于 com.firebaseui:firebase-ui-auth@4.2.0
The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art ifact with the issue. -- Project 'app' depends onto com.google.firebase:firebase-firestore@17.1.5 -- Project 'app' depends onto com.firebaseui:firebase-ui-auth@4.2.0
對于擴展調試信息,從命令行執行 Gradle./gradlew --info :app:assembleDebug 查看依賴路徑神器.此錯誤消息來自 google-services Gradle插件,在 https://報告問題github.com/google/play-services-plugins 并通過添加禁用googleServices { disableVersionCheck = false }"到您的 b uild.gradle文件.
For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https:// github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b uild.gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "myapp.com"
minSdkVersion 19
targetSdkVersion 27
versionCode 11
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
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:27.1.1'
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-firestore:17.1.5'
implementation 'com.firebaseui:firebase-ui-auth:4.2.0'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin
項目等級:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
}
}
有人可以幫幫我嗎?
推薦答案
這里有很多解決方案的答案,這些解決方案并沒有真正解決問題.以下是解決此問題的一般方法:
There are many answers here for individual solutions that do not really get down to the problem. Here is how to solve this in general:
正如原始日志輸出所示,使用以下命令在終端中運行構建很有用:
As the original log output suggests, it is useful to run the build in the terminal with the following command:
./gradlew --info assembleDebug
這將為您提供沖突中涉及的所有依賴項的列表.它看起來與此類似(我刪除了包名稱以使其更具可讀性):
This will give you a list of all dependencies that are involved in the conflict. It looks similar to this (I removed the package name stuff to make it a bit more readable):
Dependency Resolution Help: Displaying all currently known paths to any version of the dependency: Artifact(groupId=com.google.firebase, artifactId=firebase-iid)
-- task/module dep -> firebase-analytics@17.2.0
---- firebase-analytics:17.2.0 library depends -> play-services-measurement-api@17.2.0
------ play-services-measurement-api:17.2.0 library depends -> firebase-iid@19.0.0
-- task/module dep -> firebase-core@17.2.0
---- firebase-core:17.2.0 library depends -> firebase-analytics@17.2.0
------ firebase-analytics:17.2.0 library depends -> play-services-measurement-api@17.2.0
-------- play-services-measurement-api:17.2.0 library depends -> firebase-iid@19.0.0
-- task/module dep -> play-services-measurement-api@17.2.0
---- play-services-measurement-api:17.2.0 library depends -> firebase-iid@19.0.0
-- task/module dep -> firebase-iid@19.0.0
-- task/module dep -> firebase-messaging@17.1.0
---- firebase-messaging:17.1.0 library depends -> firebase-iid@[16.2.0]
-- task/module dep -> com.pressenger:sdk@4.8.0
---- com.pressenger:sdk:4.8.0 library depends -> firebase-messaging@17.1.0
------ firebase-messaging:17.1.0 library depends -> firebase-iid@[16.2.0]
從這個列表中你會知道兩件事:
From this list you get to know 2 things:
- 在哪里發現了相互沖突的依賴關系
- 設置了哪些版本的沖突依賴項
在我的情況下,沖突的依賴是 firebase-iid
:它是 @19.0.0
或 @16.2.0
In my case the conflicting dependency is firebase-iid
: It's either @19.0.0
or @16.2.0
要解決此問題,您必須在 build.gralde
中明確定義錯誤 firebase-iid
的頂級依賴項.
To fix this you must define the top-level dependency of the wrong firebase-iid
explicitly in your build.gralde
.
所以在上面的日志中,您可以看到有 2 個過時版本的 firebase-iid@16.2.0 示例.一個來自 --task/module dep ->firebase-messaging@17.1.0
來自第三方庫(pressenger)的另一個.我們對第三方庫沒有影響,所以這里無所謂.但是對于其他依賴項,我們必須使用正確的版本顯式聲明它:
So in the upper log you can see that there are 2 examples of an out-dated version of firebase-iid@16.2.0. One comes from -- task/module dep -> firebase-messaging@17.1.0
the other one from a third-party library (pressenger). We don't have influence on the third-party library, so nothing to do here.
But for the other dependency, we have to declare it explicitly with the correct version:
實現 'com.google.firebase:firebase-messaging:20.0.0'
現在構建再次運行.快樂的結局:)
Now the build works again. Happy ending :)
這篇關于在項目“應用程序"中,已解決的 Google Play 服務庫依賴項依賴于另一個確切版本的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!