Adding Firebase leads to warning about mixing versions can lead to runtime crashes

后端 未结 1 1321
遇见更好的自我
遇见更好的自我 2021-01-03 03:31

On an empty project, after adding firebase it leads to the following error:

Image Version :-

相关标签:
1条回答
  • 2021-01-03 04:09

    The error occurs because google-services is implementing some libraries, which are not using the 27.1.1 version. So we need to override the version.

    In order to do so, always try to do run this in the terminal of android studio:

    ./gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath
    

    This will show you a list of dependencies, which shows the version number along it, something like this :-

    Here we need to find those dependencies whose haven't been overwritten and have a version number like 25 or 26 and not overwritten to 27.

    Like in the above example we have com.android.support:support-v4:25.2.0

    Now we just need to add this to the dependencies block with the up to date version number.

    Finally, the dependency block looks like this:

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:27.1.1'
        implementation 'com.android.support:support-v4:27.1.1'
        implementation 'com.android.support:support-media-compat:27.1.1'
    
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        implementation 'com.google.firebase:firebase-auth:12.0.1'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.1'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    }
    

    Here we are adding

    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:support-media-compat:27.1.1'
    

    To fix the second error of

    WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.

    In project build.gradle, update the

    classpath 'com.google.gms:google-services:3.1.1'
    

    to

    classpath 'com.google.gms:google-services:3.2.0'
    
    0 讨论(0)
提交回复
热议问题