首页 > 解决方案 > 无法在 Android Studio 中连接到 Firebase

问题描述

我已经尝试了所有解决方案,但仍然无法将我的应用连接到 Firebase 服务器

https://i.stack.imgur.com/0WZbP.jpg

注意到我在 root 中使用这个 build.gradle ;

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.google.gms:google-services:4.2.0'





        buildscript {

        }

        }
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }



allprojects {


}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

而这个用于 App gradle ;

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

android {
    signingConfigs {
        config1 {
            keyAlias 'key0'
            keyPassword '000000'
            storeFile file('C:/filepath/filename.jks')
            storePassword 'password'
        }
    }
    defaultConfig {
        applicationId "com.example.last"
        minSdkVersion 21
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        signingConfig signingConfigs.config1
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
    compileSdkVersion 28
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
    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'
    implementation 'com.google.firebase:firebase-core:16.0.6'
    android {
        // ...

    }}
apply plugin: 'com.google.gms.google-services'

我安装了 google-services.json 文件

没有任何工作,我完成了所有必需的步骤,仍然没有连接

有人可以帮助我吗?

谢谢

标签: android

解决方案


您必须构建并运行您的第一个应用程序才能在“运行您的应用程序以验证安装”上打勾。


推荐阅读