Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

firebase setup on android

I can't setup the updated version of firebase on android studio. I've created json file of the project on the site firebase and copied it into the project and after coping lines in gradle:

buildscript {
    // ...
    dependencies {
        // ...
        classpath 'com.google.gms:google-services:3.0.0'
    }
}
apply plugin: 'com.android.application'
android {
  // ...
}
dependencies {
  compile 'com.google.firebase:firebase-core:9.0.1'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

I get the following error:

failed to resolve: compile 'com.google.firebase:firebase-core:9.0.0'

How can I fix it?

like image 960
Denis Windover Avatar asked May 28 '16 12:05

Denis Windover


1 Answers

I had the same problem. If you are using Android studio, you should then update google repository in SDK Manager.

enter image description here

Following is my build.grade(app)

apply plugin: 'com.android.application'
android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "package name"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    compile 'com.google.firebase:firebase-core:9.0.0'
}
apply plugin: 'com.google.gms.google-services'

And this is my build.grade(project)

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

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

allprojects {
    repositories {
        jcenter()
    }
}
like image 166
mehrdad khosravi Avatar answered Oct 10 '22 12:10

mehrdad khosravi