0

I searched for a solution and saw other answer on stackoverflow (like this solution 1) for this error.

this is my build.gradle

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    signingConfigs {
    }
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    useLibrary 'org.apache.http.legacy'

    buildTypes {
        ...
    }

}

dependencies {
implementation files('libs/jsoup-1.8.1.jar')
implementation files('libs/org.apache.http.legacy.jar')
implementation files('libs/opencsv-3.8.jar')

implementation 'com.google.firebase:firebase-database:16.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-config:16.0.0'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-messaging:17.3.2'

implementation 'com.firebaseui:firebase-ui-database:3.2.1'
implementation 'com.google.android.gms:play-services-analytics:16.0.3'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.google.android.gms:play-services-auth:16.0.0'

implementation "com.android.support:design:27.1.1"
implementation "com.android.support:customtabs:27.1.1"
implementation "com.android.support:cardview-v7:27.1.1"
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:preference-v7:27.1.1'

implementation 'com.github.bumptech.glide:glide:4.7.1'
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
    transitive = true
}
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.installreferrer:installreferrer:1.0'

}

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

but everytime I try to compile I get the error:

The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.4,15.0.4], [16.0.2,16.0.2]], but resolves to 16.0.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

This is my top-level build.gradle:

buildscript {
repositories {
    jcenter()
    maven {
        url 'https://maven.fabric.io/public'
    }

    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.4'
    classpath 'com.google.gms:google-services:4.0.1'
    classpath 'io.fabric.tools:gradle:1.24.4'

   }
}

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

    }
}

I just updated all dependencies to latest version and I don't know how to build my project.

Thank you!

Jacob Celestine
  • 1,758
  • 13
  • 23
LucasJJ
  • 623
  • 1
  • 5
  • 6

2 Answers2

0

I just figured out that the dependencies ordering it's important... now I put

implementation 'com.google.firebase:firebase-core:16.0.3'

at the top and I don't have any build problem!

this is my build gradle:

dependencies {
implementation files('libs/jsoup-1.8.1.jar')
implementation files('libs/org.apache.http.legacy.jar')
implementation files('libs/opencsv-3.8.jar')

implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-config:16.0.0'

implementation 'com.google.firebase:firebase-messaging:17.3.2'

implementation 'com.firebaseui:firebase-ui-database:3.2.1'
implementation 'com.google.android.gms:play-services-analytics:16.0.3'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.google.android.gms:play-services-auth:16.0.0'

implementation "com.android.support:design:27.1.1"
implementation "com.android.support:customtabs:27.1.1"
implementation "com.android.support:cardview-v7:27.1.1"
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:preference-v7:27.1.1'

implementation 'com.github.bumptech.glide:glide:4.7.1'
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
    transitive = true
}
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.installreferrer:installreferrer:1.0'


}
LucasJJ
  • 623
  • 1
  • 5
  • 6
0

To fix this issue I followed Google firebase integration guidelines and did the following changes in my app/build.gradle and project/build.gradle

Follow this link if you have any doubts

https://firebase.google.com/docs/android/setup

changes in app/build.gradle

    implementation (project(':react-native-firebase')) {
        transitive = false
     }
    implementation 'com.google.android.gms:play-services-base:15.0.2'
    implementation "com.google.firebase:firebase-core:16.0.1"
    implementation "com.google.firebase:firebase-messaging:17.4.0"

Changes in project/build.gradle

repositories {

        google()
        jcenter()
        mavenCentral()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'

//Below line of code should be latest if you are using firebase version 16.0 +

        classpath 'com.google.gms:google-services:4.2.0'// below google-services plugin
       
    }
    allprojects {
    repositories {
         google()// add it to top instead of bottom or somewhere in middle
        mavenLocal()
        mavenCentral()
        maven {
            url 'https://maven.google.com'
        }
       
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        
    }
}
kaushal
  • 903
  • 10
  • 17
  • 1
    After searching and search finally, your solution worked for me. I needed to change from classpath 'com.google.gms:google-services:4.0.1' to classpath 'com.google.gms:google-services:4.2.0' and it was OK – James Amo Apr 18 '19 at 20:24