Nathan Waddington Nathan Waddington - 2 months ago 32
Java Question

Firebase Tutorial 1 Friendly chat Error occurred configuring root project 'android-start'

I am trying to start the friendly chat firebase tutorial. but the gradle build throws an error, I can't really give anymore information as I dont know where to begin, however a picture is worth a thousand words, and I beleive contains everything relevant.

files downloaded from git google.json copied across

Dependencies added and applied

Build tools and IDE updated,

I noticed there is only a project build.gradle I cant find a module build.gradle I have no idea if this has anything to do with the issue tho

originally threw error about unregistered VCS root, I clicked add root, didn't help
enter image description here

both build.gradle files are blue
and when I click either one it opens the tab named android-start(also blue), but the path is C:\Users\User1\friendlychat\android-start\build.gradle

and the file contents are

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

buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.android.tools.build:gradle:2.0.0'


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

allprojects {
repositories {
jcenter()
mavenLocal()
}
}

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

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


Edit: Logcat says configure android SDK

if I click configure and set the sdk version and build tools version I get
Error:(31, 0) Could not find method android() for arguments [build_coejwo2h3fxgj0snev4rovui4$_run_closure4@512b9d86] on root project 'android-start' of type org.gradle.api.Project.
Open File

Answer

I think the error is in project.gradle... I explain about it, this dependencie is correct because is inside the project.gradle:

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

The other dependencie that needs firebase, needs is inside app.gradle:

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

And the app.gradle needs too this dependence:

compile 'com.google.firebase:firebase-core:9.6.1'

The finally gradles are these, project.gradle:

buildscript {
repositories {
    jcenter()
    mavenLocal()
}
dependencies {
    classpath 'com.google.gms:google-services:3.0.0'
    classpath 'com.android.tools.build:gradle:2.0.0'


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

allprojects {
    repositories {
        jcenter()
        mavenLocal()
    }
}

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

And the app.gradle:

...

dependencies {
    compile 'com.google.android.gms:play-services:9.6.1'
    compile 'com.google.firebase:firebase-core:9.6.1'
}

//At final of the document
apply plugin: 'com.google.gms.google-services'

Tell me if I can helps you, greetings!