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!

2 Answers 2

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/

1
  • 1
    The ordering of repositories was the great trick. Thanks guy! Jul 31, 2018 at 17:40
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.