【问题标题】:Error in Connecting my Android Studio Project to Firebase将我的 Android Studio 项目连接到 Firebase 时出错
【发布时间】:2019-07-17 12:38:09
【问题描述】:

我想将我的 android studio 连接到 Firebase,但出现此错误:

错误:无法解析 ':app@debug/compileClasspath' 的依赖关系:无法解析 androidx.appcompat:appcompat:1.0.2。 显示详细资料 受影响的模块:app

还有

错误:无法解析 ':app@debug/compileClasspath' 的依赖关系:无法解析 androidx.constraintlayout:constraintlayout:1.1.3。 显示详细资料 受影响的模块:app

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "com.example.socialnetwork"
        minSdkVersion 19
        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'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

【问题讨论】:

  • 确保您的互联网连接稳定

标签: android-studio


【解决方案1】:

首先我建议您转至Firebase Docs 以获得更清晰的信息

同样在您的 android 工作室中...您需要使缓存无效..这样做

转到文件 > 使缓存无效\重新启动 > 无效

转到Firebase Console 添加您的项目。

下载 google-services.json 文件并将其添加到您的目录

然后在你的 build.gradle 文件中添加classpath 'com.google.gms:google-services:4.2.0'

build.gradle:

  dependencies {
    // Add the following line:
    classpath 'com.google.gms:google-services:4.2.0'  // Google Services plugin
  }

之后在您的 app/build.gradle 文件中:它应该是这样的


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'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
   //FireBase
   implementation 'com.google.firebase:firebase-core:17.0.1'
}
//add this line
apply plugin: 'com.google.gms.google-services'

然后同步您的项目

【讨论】:

    猜你喜欢
    • 2022-01-12
    • 1970-01-01
    • 2019-10-13
    • 2021-11-26
    • 2019-03-25
    • 2017-02-21
    • 1970-01-01
    • 2019-12-25
    • 1970-01-01
    相关资源
    最近更新 更多