google-services.json缺少错误

时间:2016-04-29 13:15:01

标签: android json google-cloud-messaging

模块根文件夹中缺少文件google-sevices.json,即使该文件位于app目录中。我的gradle版本是2.10。我花了大部分时间来解决这个问题,但我仍无法解决这个问题。

项目级gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        classpath 'com.google.gms:google-services:2.1.0' //this is the latest version
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

App-Level gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {

        applicationId "com.myairticket.testpush3"
        minSdkVersion 9
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {

            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets { main { res.srcDirs = \['src/main/res', 'src/main/jsonfiles'\] } }
}
dependencies {
    compile fileTree(dir: 'libs', include: \['*.jar'\])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:design:23.3.0'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
}
apply plugin:'com.google.gms.google-services

1 个答案:

答案 0 :(得分:0)

我会仔细检查它是否在您的应用文件夹中,而不是在/ res文件夹中。如果您将文件拖入Android Studio并且您在Android视图而不是Project Files中,则很有可能将其复制到错误的目录中。