Error: A problem occurred configuring root project 'MyProject'

1

I'm trying to use the Firebase from Android Studio but I've made the settings on the Google website itself, and the message that appears to me is:

Gradle 'MeuProjeto' project refresh failed
Error:A problem occurred configuring root project 'Meu Projeto'.

Iaskforthehelpofsomeone,belowmyGradlecode.

//Top-levelbuildfilewhereyoucanaddconfigurationoptionscommontoallsub-projects/modules.buildscript{repositories{jcenter()}dependencies{classpath'com.android.tools.build:gradle:2.2.0'//NOTE:Donotplaceyourapplicationdependencieshere;theybelong//intheindividualmodulebuild.gradlefiles//Addthislineclasspath'com.google.gms:google-services:3.0.0'}}allprojects{repositories{jcenter()}}taskclean(type:Delete){deleterootProject.buildDir}//Addtothebottomofthefileapplyplugin:'com.google.gms.google-services'

AnotherGradleFile

applyplugin:'com.android.application'android{compileSdkVersion24buildToolsVersion"24.0.0"
    defaultConfig {
        applicationId "bbac.cursoandroidstudio"
        minSdkVersion 19
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:design:24.0.0'
    testCompile 'junit:junit:4.12'
    compile 'com.google.firebase:firebase-messaging:9.6.1'
}
    
asked by anonymous 19.11.2016 / 20:58

1 answer

0

Take this part of the build.gradle corresponding to the whole project (the first file you put):

// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services' 

So that it looks like this:

.
.
.
allprojects {
    repositories {
        jcenter()
    }

}

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

And put at the end of the build.gradule of the module (the second file you put), so that it looks like this:

.
.
.
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:design:24.0.0'
    testCompile 'junit:junit:4.12'
    compile 'com.google.firebase:firebase-messaging:9.6.1'
}


apply plugin: 'com.google.gms.google-services'
    
19.11.2016 / 23:46