0

I know that this question has been asked a lot, but the answer is always to go to your SDK Manager and make sure that Google Play Services and Google Repository are installed/updated.

Mine are both updated and installed. Google Play services is version 44 and Google Repository is version 58. Also, if I check for an update of Android Studio, it says that I have the latest version installed. So, this isn't the issue. Can anyone help me?

Here's my app build.gradle file

   apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion '25.0.2'

defaultConfig {
    applicationId "com.angelakarl.flashchatnewfirebase"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
  }

  dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.google.firebase:firebase-database:11.2.2'
compile 'com.google.firebase:firebase-auth:11.2.2'


}

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

Here's my other build.gradle file

  // 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.3.3'
    classpath 'com.google.gms:google-services:3.1.0'


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

 allprojects {
     repositories {
         jcenter()
     }
 }

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

The errors I'm getting are

Error:(27, 13) Failed to resolve: com.google.firebase:firebase-auth:11.2.2

Error:Failed to resolve: com.google.firebase:firebase-core:11.2.2

Error:(26, 13) Failed to resolve: com.google.firebase:firebase-database:11.2.2

KENdi
  • 7,576
  • 2
  • 16
  • 31
Ang
  • 83
  • 1
  • 3
  • 11

1 Answers1

2

Please add Google's Maven repository like this to your project level build.gradle file:

allprojects 
{
    repositories 
    {
        jcenter()
        maven { url "https://maven.google.com" // Google's Maven repository}
    }
}
harshit batra
  • 75
  • 1
  • 13
Sneh Pandya
  • 8,197
  • 7
  • 35
  • 50
  • Your last comment worked changing the dependency to 11.0.4. If it's not released yet, why does Google give the gradle dependency line 11.2.2 [here](https://firebase.google.com/docs/android/setup)? – Ang Sep 14 '17 at 15:01
  • Google now relies on its Maven Repository for its dependencies. Please mark as answer and vote if it helped :) – Sneh Pandya Sep 14 '17 at 15:03
  • 1
    It actually doesn't work if I add the Maven Repository. My error is: Error:(22, 0) Could not find method maven() for arguments [build_sdiqbiqltjtd3q6169ye9png$_run_closure1$_closure4$_closure5@44a22eb8] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. – Ang Sep 14 '17 at 15:08
  • You need to specify url **inside** the maven block as shown in my answer. Also check if you have implemented the maven block in your **project level** `build.gradle` file and not in **app level** `build.gradle` file. – Sneh Pandya Sep 14 '17 at 15:10
  • It is both inside the maven block and inside the project level build.gradle file. I think I'll just change the dependency to 11.0.4 since that worked. – Ang Sep 14 '17 at 15:19
  • 1
    allprojects { repositories { jcenter() maven { url "https://maven.google.com" // Google's Maven repository } } } – Sangeeth Nandakumar Sep 15 '17 at 11:29