0

I wanted to add firebase sdk to my android studio project written in kotlin

as per firebase website it asks to add

buildscript {
  repositories {
    // Make sure that you have the following two repositories
    google()  // Google's Maven repository

    mavenCentral()  // Maven Central repository

  }
  dependencies {
    ...
    // Add the dependency for the Google services Gradle plugin
    classpath 'com.google.gms:google-services:4.3.13'

  }
}

allprojects {
  ...
  repositories {
    // Make sure that you have the following two repositories
    google()  // Google's Maven repository

    mavenCentral()  // Maven Central repository

  }
}

but what i see in my android in build.gradle

plugins {
    id 'com.android.application' version '7.4.0' apply false
    id 'com.android.library' version '7.4.0' apply false
    id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
}

Documentation are not upto date what to do?

I Tried to add it in setting.gradle with entire buildscript block as well I did the same thing with buil.gradle

  • Most likely this [answer](https://stackoverflow.com/questions/72224454/execution-failed-for-task-appmapdebugsourcesetpaths-error-while-evaluatin) will help. – Alex Mamo Jan 14 '23 at 10:11

1 Answers1

0

This is quite a long process. Start by going over the required processes like:

  • registering with firebase;
  • setting up the android environment (where you are)
  • setting up the server environment (most likely your will need this)

For android implementations, you can follow this: https://firebase.google.com/docs/cloud-messaging/android/client

For server-side, you can follow this if on PHP: https://firebase-php.readthedocs.io/en/stable/cloud-messaging.html

But, specifically to your question:

There are two gradles; Build.gradle(project) and Build.gradle(Module--app-name) At the module one, where your min-sdk and target-sdk settings are, at the very top and not inside any of the current settings, add these:

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
}
apply plugin: 'com.android.application'

The one you are seeing is in the project-gradle. In it some re-ordering may also be required. Just be sure to use the exact one instructed: project or app (module). It took me a while to find out this - especially the placement of the plugins entry.

Ajowi
  • 449
  • 3
  • 12