android - 如何正确应用google服务插件?

标签 android plugins google-play-services

我正在做一个项目,我需要将谷歌服务插件应用到我的代码中。我已经在 build.gradle 项目和模块中这样做了,但每次运行我的应用程序时,我都会收到以下警告。

请在构建文件的底部应用 google-services 插件。

任何帮助都会很棒!

此外,我是编码初学者,请注意我的应用无法运行可能很重要。当我尝试运行模拟器时,我在模拟器中遇到运行时错误: ________ 不停地停下 应用信息 关闭应用

这是我的 build.gradle Module:app

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 26
        defaultConfig {
            applicationId "edmt.dev.androidgeofire"
            minSdkVersion 15
            targetSdkVersion 26
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {

        implementation fileTree(dir: 'libs', include: ['*.jar'])

        androidTestImplementation 
        ('com.android.support.test.espresso:espresso-core:3.0.2', {

            exclude group: 'com.android.support', module: 'support-annotations'

        })

        implementation 'com.h6ah4i.android.widget.verticalseekbar:verticalseekbar:0.7.2'

        implementation 'com.firebase:geofire-android:2.3.1'

        implementation 'com.google.firebase:firebase-database:16.1.0'

        implementation 'com.android.support:appcompat-v7:26.1.0'

        implementation 'com.android.support.constraint:constraint-layout:1.1.3'

        implementation 'com.google.android.gms:play-services-maps:16.1.0'

        testImplementation 'junit:junit:4.12'

        implementation 'com.google.android.gms:play-services-base:16.1.0'

        implementation 'com.google.android.gms:play-services-location:16.0.0'

        }

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

我不确定我还需要包括什么来帮助任何人理解,所以如果有人需要任何其他东西,我很乐意添加。

最佳答案

尝试像这样更改您的 build.gradle(project)

buildscript {
repositories {
    google()
    jcenter()
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.3.2'
    classpath 'com.google.gms:google-services:4.2.0'
}
}

不要忘记改变

classpath 'com.android.tools.build:gradle:3.3.2'

到你实际的gradle类路径

关于android - 如何正确应用google服务插件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55539495/

相关文章:

android - 如何从 RecyclerView 中取出 subview ?

elasticsearch - 是否有任何适用于 ELK 堆栈的开源警报和报告插件可用?

grails - 在grails 2.2.3上安装本地dojo插件

android - Google Play 服务无法验证,操作 : SIGN_IN status: 10

Android - 什么数据结构来存储视频字幕以在 O(1) 时间内获取它们

android - 在自定义对话框的 TextView 中设置文本

android - 添加 AndroidInjector 时 Dagger 缺少绑定(bind)

c++ - 如何开发基于插件的应用程序?

android - eclipse打开gcm-demo-client时GCM Registrar无法解析

java - 更新后的谷歌服务