【问题标题】:Could not find com.google.gms:google-services:4.1.0. Searched in the following locations:找不到 com.google.gms:google-services:4.1.0。在以下位置搜索:
【发布时间】:2019-04-17 15:05:43
【问题描述】:

我正在尝试将 firebase 添加到我的项目中,我正在按照 firebase 文档https://firebase.google.com/docs/android/setup?authuser=0 中的步骤进行操作 请帮忙!当我尝试同步 gradle 时出现此错误。

找不到 com.google.gms:google-services:4.1.0。 在以下位置搜索: https://repo.maven.apache.org/maven2/com/google/gms/google-services/4.1.0/google-services-4.1.0.pom https://repo.maven.apache.org/maven2/com/google/gms/google-services/4.1.0/google-services-4.1.0.jar

为什么会这样,我访问了这个链接 https://repo.maven.apache.org/maven2/com/google/gms/google-services/ 以确保存储库有那个 .pom 或 .jar,但我看到了这个

buildscript {
repositories {
    mavenCentral()
    flatDir {
        dirs 'libs'
    }
    google()

}
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
}

}


....
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(":mupdf")
implementation 'org.altbeacon:android-beacon-library:2.+@aar'
implementation 'com.android.support:appcompat-v7:22.2.1'
implementation 'com.journeyapps:zxing-android-embedded:3.0.2@aar'
implementation 'com.google.zxing:core:3.2.0'
implementation 'com.android.support:support-v4:22.2.1'
implementation 'com.android.support:design:22.2.1'
implementation 'com.weigan:loopView:0.1.2'
implementation 'com.google.firebase:firebase-core:16.0.5'
// Add the In-App Messaging depencency:
implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.5'

} 应用插件:'com.google.gms.google-services'

【问题讨论】:

  • 请同时添加其他 build.gradle 文件的内容。

标签: android firebase firebase-in-app-messaging


【解决方案1】:
buildscript {
repositories {
mavenCentral()
flatDir {
    dirs 'libs'
}
google()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

...

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-ads:17.1.1'
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'
apply plugin: 'com.android.application'

【讨论】:

  • v4.2.0是官方的吗?它没有出现在官方文档中。此外,我在尝试使用该版本时遇到了同样的错误(找不到 com.google.gms:google-services:4.2.0)
  • 对我来说同样的问题:(
【解决方案2】:

尝试添加 google 存储库,例如: maven { url "https://maven.google.com" }

而不是 google()

【讨论】:

    猜你喜欢
    • 2019-05-11
    • 1970-01-01
    • 2018-09-25
    • 2020-11-13
    • 1970-01-01
    • 1970-01-01
    • 2019-05-11
    • 2017-11-14
    • 2019-03-30
    相关资源
    最近更新 更多