“无法获取资源” Android Studio Gradle同步错误

时间:2018-12-05 13:07:33

标签: android firebase android-studio gradle firebase-realtime-database

我想将Google Firebase的ML-Kit用于带有Android Studio 3.2.1的项目。但是,当我“用Gradle文件同步项目”时,我可以see表示gradle无法获得某些依赖关系,尽管这并不能阻止Gradle“成功”同步。所有这些依赖项都与google-services或firebase相关。 这些是我的build.gradle(应用程序模块)依赖项:

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-ml-vision:18.0.2'
implementation 'com.google.firebase:firebase-ml-common:16.1.6'


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'
}
apply plugin: 'com.google.gms.google-services'

这是我的最高级别:

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
    classpath 'com.google.gms:google-services:4.1.0'



    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    google()
    jcenter()
    maven { url "https://maven.google.com" }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

我已经检查了SDK Tools settings。 您是否有其他想法会导致此错误? 预先谢谢你!

编辑:就像描述为here一样,我尝试使用命令行(gradlew assembleDebug)构建应用程序,但没有看到任何错误。我们会看到,这可能行得通。

2 个答案:

答案 0 :(得分:0)

更改此

classpath 'com.google.gms:google-services:4.1.0'

对此

classpath 'com.google.gms:google-services:4.2.0'

答案 1 :(得分:0)

好吧,如果您在每个命令行中使用gradlew clean assembleDebug构建应用程序,则看起来这些错误没有问题。 Atleast人脸检测现在可以正常工作。