【问题标题】:Error when connecting Firebase to Android Studio [duplicate]无法将firebase连接到android studio [重复]
【发布时间】:2022-01-13 07:09:50
【问题描述】:

我正在尝试学习使用 android studio 创建 android 应用程序

应用程序是空白的,除非主 Activity,否则还没有页面

我在 firebase 上做了项目并输入了名称 (com.example.connect)

然后我将 jason 文件添加到应用程序位置,然后我做了所有事情

但是当我点击连接时仍然会弹出这个错误

(无法解析 Android 应用程序模块的 Gradle 配置。解决 gradle 构建问题和/或重新同步)

每当我观看解决此问题的视频时,都可以解决我的问题! 我能做什么?

构建 gradle APP

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()

    }
}
rootProject.name = "RUVOLT"
include ':app'

构建 gradle 模块

plugins {
    id 'com.android.application'
    id 'com.google.firebase.crashlytics'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.example.ruvolt"
        minSdk 19
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

apply plugin: 'com.google.gms.google-services'
dependencies {
    implementation 'com.google.firebase:firebase-analytics:20.0.2'
    implementation platform('com.google.firebase:firebase-bom:29.0.3')
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
    implementation 'com.google.firebase:firebase-crashlytics:18.2.6'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

【问题讨论】:

标签: javascript android firebase gradle


【解决方案1】:

在您的 build.gradle 中应用这些插件和库以添加 firebase。

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'


implementation platform('com.google.firebase:firebase-bom:26.0.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-messaging:23.0.0'
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'

在您的类路径文件中,请确认您在依赖项标签中正确输入了这些行;

classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'

是的,显然请确保您已在项目文件的应用部分下添加了谷歌的 JSON 文件。如需正确参考,请转到此页面https://developer.android.com/studio/write/firebase

【讨论】:

    【解决方案2】:
    1. 添加谷歌服务插件

       plugins {
       id 'com.android.application'
       id 'com.google.gms.google-services'
       id 'com.onesignal.androidsdk.onesignal-gradle-plugin'
      

      }

    2. 并检查构建 gradle 项目的 google 服务依赖项

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

    【讨论】:

      猜你喜欢
      • 2021-02-08
      • 2020-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-26
      • 1970-01-01
      • 2021-11-15
      • 2015-11-29
      相关资源
      最近更新 更多