繁体   English   中英

无法使用 Android Studio 和 Firebase 解决依赖关系

[英]Unable to resolve dependencies with Android Studio and Firebase

以下是我得到的错误,请帮助我!

错误:无法解析“:app@debug/compileClasspath”的依赖关系:

无法解析 com.google.firebase:firebase-core:17.2.0。

错误:无法解析“:app@debug/compileClasspath”的依赖关系:

无法解析 com.google.firebase:firebase-config:19.0.3。

错误:无法解析“:app@debug/compileClasspath”的依赖关系:

无法解析 com.google.android.gms:play-services-measurement-base:[17.2.0]。

错误:无法解析“:app@debug/compileClasspath”的依赖关系:

无法解析 com.google.android.gms:play-services-measurement-impl:[17.2.0]。

错误:无法解析“:app@debug/compileClasspath”的依赖关系:

无法解析 com.google.android.gms:play-services-measurement-sdk-api:[17.2.0]。

错误:无法解析“:app@debugAndroidTest/compileClasspath”的依赖关系:

无法解析 com.google.firebase:firebase-core:17.2.0。

错误:无法解析“:app@debugAndroidTest/compileClasspath”的依赖关系:

无法解析 com.google.firebase:firebase-config:19.0.3。

错误:无法解析“:app@debugAndroidTest/compileClasspath”的依赖关系:

无法解析 com.google.android.gms:play-services-measurement-base:[17.2.0]。

错误:无法解析“:app@debugAndroidTest/compileClasspath”的依赖关系:

无法解析 com.google.android.gms:play-services-measurement-impl:[17.2.0]。

错误:无法解析“:app@debugAndroidTest/compileClasspath”的依赖关系:无法解析com.google.android.gms:play-services-measurement-sdk-api:[17.2.0]。

错误:无法解析“:app@debugUnitTest/compileClasspath”的依赖关系:无法解析com.google.firebase:firebase-core:17.2.0。

错误:无法解析“:app@debugUnitTest/compileClasspath”的依赖关系:无法解析com.google.firebase:firebase-config:19.0.3。

错误:无法解析“:app@debugUnitTest/compileClasspath”的依赖关系:无法解析com.google.android.gms:play-services-measurement-base:[17.2.0]。

错误:无法解析“:app@debugUnitTest/compileClasspath”的依赖关系:无法解析com.google.android.gms:play-services-measurement-impl:[17.2.0]。

错误:无法解析“:app@debugUnitTest/compileClasspath”的依赖关系:无法解析com.google.android.gms:play-services-measurement-sdk-api:[17.2.0]。

 //app level build.gradle apply plugin: 'com.android.application' android { compileSdkVersion 29 buildToolsVersion "29.0.2" defaultConfig { applicationId "com.hfad.firebaselinkedin" minSdkVersion 16 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.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.firebase:firebase-core:17.2.0' implementation 'com.google.firebase:firebase-analytics:17.2.0' implementation 'com.google.firebase:firebase-config:19.0.3' implementation 'com.google.firebase:firebase-auth:19.1.0' } apply plugin: 'com.google.gms.google-services'
 //project level build.gradle buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.5.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files classpath 'com.google.gms:google-services:4.3.2' } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir }

更新

  1. 尝试“文件”->“使缓存无效/重新启动-> 无效并重新启动”
  2. 尝试清理你的项目根目录下的.gradle和.idea目录。

Go 到文件 -> 其他设置 -> 默认设置(在较新版本中为新项目设置) -> 构建,执行,部署 -> 构建工具 -> Gradle -> 并取消选中离线工作选项。

从这个答案

如果您正在使用 VPN,请在同步之前关闭它或更改 IP,因为它们可能被用于对 google 进行 DDOS 攻击

如果上述步骤对您没有帮助,请在您的项目级别中尝试build.gradle

allprojects {
    repositories {
        maven { url "http://dl.bintray.com/populov/maven" }           
        maven { url "https://maven.google.com" } // Google's Maven repository - FCM
        maven {
            url 'https://dl.bintray.com/azeesoft/maven'
        }
        google()
        jcenter()
        mavenCentral()
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM