无法确定 com.google.android.gms:play-services-vision:18.0.0 的项目



我无法在 Android Studio 中构建我的项目。我正在尝试使用谷歌视觉 API 进行面部检测,到目前为止它运行良好,但由于这个原因我无法清理/构建我的项目

这是我的构建错误消息

Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
Could not determine artifacts for com.google.android.gms:play-services-vision:18.0.0
Could not get resource 'https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-vision/18.0.0/play-services-vision-18.0.0.aar'.
Could not HEAD 'https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-vision/18.0.0/play-services-vision-18.0.0.aar'.
Remote host closed connection during handshake
SSL peer shut down incorrectly

这是我的build.gradle文件(应用程序级别(

apply plugin: 'com.android.application'
android {
    compileSdkVersion 29
    buildToolsVersion "29.0.0"
    defaultConfig {
        applicationId "com.example.facedetect"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.volley:volley:1.1.1'
    implementation "com.github.bumptech.glide:glide:4.9.0"
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    implementation 'com.google.android.gms:play-services-vision:18.0.0'

    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.mindorks:paracamera:0.2.2'
}
apply plugin: 'com.google.gms.google-services'

项目级 build.gradle

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
    }
}
allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.google.com'}
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}
buildscript {
    dependencies {
        // Add this line
        classpath 'com.google.gms:google-services:4.3.0'
    }
}

当我删除

implementation 'com.google.android.gms:play-services-vision:18.0.0

项目生成成功。我添加依赖项的方式有问题吗?

我认为您的依赖项类路径有问题。您创建了两个构建脚本依赖项。相反,您可以在同一构建脚本中包含一个或多个插件(依赖项(。

你可以有根build.gradle,如下所示:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        classpath 'com.google.gms:google-services:4.3.0'
    }
}
allprojects {
    repositories {
        google()
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

此外,您不必单独编写谷歌maven url maven { url 'https://maven.google.com'},因为google()会为您做同样的事情。

我想通了。看起来我需要使缓存失效并重新启动安卓工作室和我的计算机。感谢您的帮助!

最新更新