当我尝试将 apply plugin: 'com.google.gms.google-services' 放在构建 gradle 的底部或应用程序构建 gradle 内的其他任何位置时,出现以下错误:
In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[19.0.
2]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.
Dependency failing: com.google.android.gms:play-services-vision-image-label:18.0.3 -> com.google.android.gms:play-servic
es-vision-common@[19.0.2], but play-services-vision-common version was 19.1.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-ml-vision-object-detection-model@{strictly 19.0.5}
-- Project 'app' depends onto com.google.android.gms:play-services-vision-common@{strictly 19.1.0}
-- Project 'app' depends onto com.google.firebase:firebase-ml-vision@{strictly 24.0.3}
-- Project 'app' depends onto com.google.firebase:firebase-ml-vision-internal-vkp@{strictly 17.0.1}
-- Project 'app' depends onto com.google.firebase:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6107081304030012044c0c0d4c170812080e0f4c0e030b0402154c050415040215080e0f4c0c0e05040d2150584f514f54" rel="noreferrer noopener nofollow">[email protected]</a>
-- Project 'app' depends onto com.google.firebase:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f99f908b9c9b988a9cd49495d48f908a909697b9cbcdd7c9d7ca" rel="noreferrer noopener nofollow">[email protected]</a>
-- Project 'app' depends onto com.google.android.gms:play-services-vision-image-label@{strictly 18.0.3}
-- Project 'app' depends onto com.google.android.gms:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cebea2afb7e3bdabbcb8a7adabbde3a3a2a5a7bae3a8afadabe3aaabbaabadbaa7a1a08efff8e0ffe0fe" rel="noreferrer noopener nofollow">[email protected]</a>
-- Project 'app' depends onto com.google.android.gms:play-services-vision@{strictly 20.1.0}
-- Project 'app' depends onto com.google.android.gms:play-services-mlkit-face-detection@{strictly 16.1.0}
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.
我在应用程序级别的 build.gradle 是:
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.mlkitfacedetection"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.gms:play-services-mlkit-face-detection:16.1.0'
implementation 'com.google.firebase:firebase-ml-vision:24.0.3'
implementation 'com.google.firebase:firebase-ml-vision-object-detection-model:19.0.5'
def camerax_version = "1.0.0-beta03"
// CameraX core library using camera2 implementation
implementation "androidx.camera:camera-camera2:$camerax_version"
// CameraX Lifecycle Library
implementation "androidx.camera:camera-lifecycle:$camerax_version"
// CameraX View class
implementation "androidx.camera:camera-view:1.0.0-alpha10"
}
apply plugin: 'com.google.gms.google-services'
我无法解决该错误。另一个应用程序中的相同代码运行得非常好。 我正在使用在 firebase 上注册的另一个应用程序中的 google-serivices.json 文件。这不是问题的根源吗?
最佳答案
我测试了这个解决方法,这似乎有效。在您的 dependency
block 中添加以下内容:
implementation 'com.google.android.gms:play-services-vision-image-label:18.0.4'
关于android - 'com.google.gms.google-services'插件与android应用程序集成时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63056088/