0

In my Android project, I have following configuration in my app level gradle file-

build.gradle(module:app)

android {

    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId "com.XXX"
        minSdkVersion 18
        targetSdkVersion 28
        versionCode 1
        versionName "6.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        manifestPlaceholders = [
                onesignal_app_id               : 'my app id',
                // Project number pulled from dashboard, local value is ignored.
                onesignal_google_project_number: 'REMOTE'
        ]

    }
    buildTypes {
        release {
            minifyEnabled false

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        javaMaxHeapSize "2g"
    }
    repositories {
        mavenCentral()
    }
}


repositories {
    flatDir {
        dirs 'libs'
    }
}


dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'

    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.github.bluejamesbond:textjustify-android:2.1.6'
    androidTestImplementation 'junit:junit:4.12'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.8@aar') {
        transitive = true
    }

    implementation 'com.facebook.android:facebook-android-sdk:[4,5)'

    implementation 'com.google.firebase:firebase-core:11.6.0'
    implementation 'com.google.android.gms:play-services-analytics:11.6.0'
    implementation 'com.google.firebase:firebase-messaging:11.6.0'


}

And here's the configuration of my project level gradle file-

build.gradle(module:project)

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

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

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

And inside my Manifest.xml file I have set the follwoing lines in application tag-

<application
    android:name="android.support.multidex.MultiDexApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

My code used to work perfectly before today. But today when I opened my project it showing the following error while gradle building-

ERROR: Failed to resolve: com.google.firebase:firebase-measurement-connector:11.6.0 Show in Project Structure dialog Affected Modules: app

ERROR: Failed to resolve: com.google.android.gms:play-services-ads-identifier:11.6.0 Show in Project Structure dialog Affected Modules: app

I have tried the following suggestions but didn't work for me- failed to resolve com.google.android.gms:play-services-add:11.6.0

So, i need a solution to solve this issue to make my gradle build successful and use the mentioned dependencies of firebase.

S. M. Asif
  • 3,437
  • 10
  • 34
  • 58
  • try to use a new versions of these dependencies, that may solve the problem – amm965 Oct 17 '19 at 17:26
  • I did update but it is showing the following error- Error: Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from AndroidManifest.xml:22:18-86 is also present at AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:13:5-234:19 to override. app main manifest (this file), line 21 – S. M. Asif Oct 17 '19 at 18:49

2 Answers2

2

add this in build.gradle (:app)

implementation platform('com.google.firebase:firebase-bom:30.3.1')
0

In your repositories blocks, try putting google() before jcenter().

Example:

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

becomes:

allprojects {
    repositories {
        google()
        maven { url "https://jitpack.io" }
        jcenter()
    }
}
Jarvis
  • 392
  • 1
  • 6