【问题标题】:"Could not get resource" Android Studio Gradle Sync Error“无法获取资源”Android Studio Gradle 同步错误
【发布时间】:2018-12-05 13:07:32
【问题描述】:

我想将 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)构建应用程序,但没有看到任何错误。这可能会奏效,我们拭目以待。

【问题讨论】:

  • 尝试将应用插件:'com.google.gms.google-services'移到文件顶部
  • 感谢您的帮助!可悲的是,它没有用:/
  • stackoverflow.com/questions/53246632/… 这看起来一样,但没有回答
  • 我看过这篇文章,但它无缘无故关闭了://

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


【解决方案1】:

改变这个

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

到这里

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

【讨论】:

  • 感谢您的帮助!但这并没有解决问题
  • 你把项目迁移到android-x了吗?
  • 不,应该吗?我以前从未听说过 android-x
  • “重构 > 迁移 Android X”并选中“将项目备份为 Zip 文件”以防万一。也许它会起作用。我不确定。
  • 嗯,没什么区别,恐怕。但是还是谢谢你帮助我:) offtopic: AndroidX 真的更好吗?到目前为止,它似乎没有造成任何问题,它到底在做什么?
【解决方案2】:

好的,如果您在每个命令行中使用 gradlew clean assembleDebug 构建应用程序,这些错误似乎没有问题。至少人脸检测现在工作正常。

【讨论】:

    猜你喜欢
    • 2019-03-15
    • 2019-05-17
    • 2018-12-06
    • 2015-03-02
    • 1970-01-01
    • 2020-11-08
    • 2018-04-27
    • 1970-01-01
    • 2023-04-05
    相关资源
    最近更新 更多