Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find com.google.firebase:firebase-analytics:

I am new to firebase and try to implement firebase in next project. I included dependencies as below but it shows the above error. I would be grateful if anyone can provide information.

My builder.gradle(app)files is as follows:

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
    implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'

    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-firestore'

    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
apply plugin: 'com.google.gms.google-services'
like image 634
Krishna Avatar asked Oct 29 '25 05:10

Krishna


1 Answers

When you integrate Firebase into your app, you must choose one of two ways of adding dependencies, according to the documentation. You can either choose to use specific versions of each dependency, like this:

    implementation 'com.google.firebase:firebase-analytics:18.0.0'
    implementation 'com.google.firebase:firebase-firestore:22.0.0'

Or, you can use the Firebase BoM to choose them for you, based on a single BoM version that applies specific compatible versions for you:

    // Import the Firebase BoM
    implementation platform('com.google.firebase:firebase-bom:26.1.0')

    // versions for Firebase SDKs are chosen automatically by the BoM
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-firestore'

It looks like you tried to use the BoM, but didn't add a line for choosing the platform.

like image 108
Doug Stevenson Avatar answered Oct 31 '25 19:10

Doug Stevenson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!