Can not Link/Connect Android Studio with Firebase

Viewed 11797

I have been trying to connect Android studio 4.1 with Firebase but it is not getting linked. I followed the instruction given on the firebase website like copying the dependencies, plugins, etc. into the app Gradle build and Project Gradle Build. My Gradle version is 6.5 and Gradle plugin is 4.1. The Error shown is:

org.codehaus.groovy.ast.expr.TupleExpression cannot be cast to org.codehaus.groovy.ast.expr.ArgumentListExpression

org.codehaus.groovy.ast.expr.TupleExpression cannot be cast to org.codehaus.groovy.ast.expr.ArgumentListExpression Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)

The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.

Stop Gradle build processes (requires restart)

Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project. Error Description In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

7 Answers

I believe i found the problem. If you use

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

to your build.gradle(module) like its instructed you get this error.

Instead change apply plugin to id

id 'com.google.gms.google-services'

I haven't finish the app but when I sync, it's successful

Using the Firebase guide to link my app with Firebase, the problem is that you have to scatter the plugins by these 2 ways of implementation:

//First way to implement plugins
plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

//Second way to implement plugins
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

Taking out the apply plugin ones from the {} of plugins solved my link issues ;)

This Error Rise due to if you are using

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

If You replace apply plugin: with id in build.gradle than this error will be solved. After change

id 'com.google.gms.google-services'

I do not know how correct this information is, however, I think you should remove the block of code

pugins{
  id '...'
}

Instead, start adding code/plugins like:

apply plugin: "com..."

Essentially all the plugins your firebase suggests. It works like magic and you do not have to lose the plugin.

Example Screen Shot

//First way to use Plugin

plugins {
    id 'com.android.application'
}

//Second way to use Plugin.

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

I solved my problem by adding:

plugins {
   id 'kotlin-kapt'
}

Just Remove Flower Parenthesis mention like this below with out flower brackets whenever using apply plugins

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
Related