Nugo Japaridze
Nugo Japaridze

Reputation: 11

Gradle error when adding firebase

I have a problem in gradle when I am adding firebase or google ads:

here is the error.

Also you can check the code from gradle below. What am I missing?

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.jnugzar"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')


    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'


    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-ads:15.0.1'



}

Upvotes: 0

Views: 1623

Answers (3)

Abilogos
Abilogos

Reputation: 5055

my gradle sync gets error when adding the firebase to project and i have solved my problem with adding this lines to gradle.properties :

android.useAndroidX=true
android.enableJetifier=true

and adding firebase.core to my module gradle dependencies

Upvotes: 0

Paraskevas Ntsounos
Paraskevas Ntsounos

Reputation: 1777

Just update your firebase to the latest version (update firebase-ads) and add firebase-core, for version you can check this link:

implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-ads:15.0.1'

And make sure you are using these:

classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.1'

Try this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.jnugzar"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')


    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:customtabs:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:animated-vector-drawable:27.1.1'
    implementation 'com.android.support:support-media-compat:27.1.1'

    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'


    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-ads:15.0.1'

}

And:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

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

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

Upvotes: 1

Add implementation 'com.google.firebase:firebase-core:16.0.0' in Module Gradle
and In Root gradle make sure you have setup properly

buildscript {

     repositories {
        google()
        jcenter()
      }
    dependencies {
      classpath 'com.android.tools.build:gradle:3.1.2'


     // NOTE: Do not place your application dependencies here; they belong
     // in the individual module build.gradle files
      classpath 'com.google.gms:google-services:4.0.1'
    }
 }

Upvotes: 1

Related Questions