0

I have added Firebase messaging to my app using firebase tools in Android studio and I faced a problem in my app (there was no error before adding firebase messaging). My current setting in App level gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.test"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-messaging:20.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
apply plugin: 'com.google.gms.google-services'

I have updated all dependencies using project struture menu to latest versions. As I write this question the latest version for firebase-messaging is 20.0.0 and for com.google.gms:google-services:4.3.2 so the problem is not about updating to latest versions.

This is Project level gradle:

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

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

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

I have checked this Q/A but this is not my case as I have google() in repository before everything else. Also as I am working in androidx environment the case is not about support.v4.

When I rebuild the project I get this error:

ERROR: Failed to resolve: play-services-basement
Affected Modules: app

Ali Sheikhpour
  • 10,475
  • 5
  • 41
  • 82

1 Answers1

0

The error was gone by adding the following line manually to the dependencies of APP gradle:

implementation 'com.google.android.gms:play-services-basement:17.1.1'

I wonder why should a programmer know all background dependecies of a package and why they are not implemented automatically.

Ali Sheikhpour
  • 10,475
  • 5
  • 41
  • 82