3

I have the follow app/build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        ...
        minSdkVersion 19
        targetSdkVersion 27
        ...
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    useLibrary 'org.apache.http.legacy'
}

dependencies {
    implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.google.firebase:firebase-messaging:11.8.0'
    implementation 'com.google.firebase:firebase-core:11.8.0'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.github.IntruderShanky:scatter-piechart:1.0.0'
    implementation 'com.etsy.android.grid:library:1.0.5'
    implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
    implementation 'com.google.zxing:core:3.3.0'
    testImplementation 'junit:junit:4.12'
}

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

And follow project/build.gralde

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

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://jitpack.io"
        }
        google()
    }
}

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

When I'm hovering mouse above firebase implementations I get the follow warnings

implementation 'com.google.firebase:firebase-messaging:11.8.0' show me

A newer version of com.google.firebase:firebase-messaging than 11.8.0 is available: 17.1.0

and implementation 'com.google.firebase:firebase-core:11.8.0' show me

A newer version of com.google.firebase:firebase-core than 11.8.0 is available: 16.0.1

Then I do the sugestion and update my implementation to available version as follow

implementation 'com.google.firebase:firebase-messaging:17.1.0'
implementation 'com.google.firebase:firebase-core:16.0.1'

and sync my project. But the project show me the follow errors

Failed to resolve: play-services-base Open File

Failed to resolve: play-services-tasks Open File

Failed to resolve: play-services-stats Open File

Failed to resolve: play-services-ads-identifier Open File

Failed to resolve: play-services-basement Open File

I'm trying solve it for a long time and nothing work. Please, help me to solve it!

Abner Escócio
  • 2,697
  • 2
  • 17
  • 36

2 Answers2

4

In the top level gradle file add the following:

   buildscript {
      repositories {
              google()
              jcenter()
          }



 dependencies {
      classpath 'com.android.tools.build:gradle:3.1.3'
      classpath 'com.google.gms:google-services:4.0.2'
       }
    }

    allprojects {
         repositories {
                  google()
                 jcenter()
      }
    }

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

Add the google() repo before jcenter() and use the latest google service plugin version 4.0.2

https://bintray.com/android/android-tools/com.google.gms.google-services/

Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
0

Make sure you are connected to a good network

Try adding Google maven repository into app's build.gradle file:

repositories {
    maven { url "https://maven.google.com" }
}

If step 1 won't work, remove gradle from your project root folder and rebuild your project again.

Try another

Goto >file -> other settings -> Under build, execution, and deployment -> you will see Gradle. uncheck the checkbox offline work

olajide
  • 972
  • 1
  • 13
  • 26