1

I am working on an App project using Android studio (language is java) and i tried to infuse the firebase in build.gradle and app.gradle and got the following error "only id(String) method calls allowed in plugins {} script block" and i am lost as to how to solve the issue. Below is a copy of gradle files for your inspection

Build.Gradle App

plugins {
id 'com.android.application'

android {
    // ...
}
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.example.openingscreen"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {

implementation 'androidx.appcompat:appcompat:'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation platform('com.google.firebase:firebase-bom:26.5.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-auth:19.3.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.firbase:firebase-auth:19.3.1 '
}

apply plugin: 'com.google.gms.google-services'
Amrish Kakadiya
  • 974
  • 1
  • 7
  • 25
Josh Coker
  • 13
  • 5
  • Have you added classpath "com.google.gms:google-services:4.3.5" in your build gradel project in your project as it is related to firebase may help – Aadesh Mishra Mar 05 '21 at 10:23
  • I just added this line and no luck. Error: 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 – Josh Coker Mar 05 '21 at 10:42
  • Remove all dependency and syn then again add all dependency you need will solve the problem – Aadesh Mishra Mar 05 '21 at 10:51

1 Answers1

2

Make sure you added google-services:4.3.5 in your top level build.gradle section.

The top-level build.gradle file, located in the root project directory, defines build configurations that apply to all modules in your project.

 buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.1"
        classpath 'com.google.gms:google-services:4.3.5' //this

       
    }
}

And then rectify your Module level build.gradle section.

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

Then goto gradle-wrapper.properties section and make sure you using

distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip

Finally Clean-Rebuild-Gradle

IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
  • 1
    Thanks, I just tried it and this is what i got after synching Gradle 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. – Josh Coker Mar 05 '21 at 10:34
  • `plugins { id 'com.android.application' id 'com.google.gms.google-services' }` – IntelliJ Amiya Mar 05 '21 at 10:52
  • got this error: only id(String) method calls allowed in plugins {} script block – Josh Coker Mar 05 '21 at 11:06
  • https://stackoverflow.com/questions/48610901/only-build-script-and-other-plugins-script-blocks-are-allowed-before-plugins @JoshCoker – IntelliJ Amiya Mar 05 '21 at 11:09
  • @Amiya have followed the instructions as you outlined but came up with this Could not resolve com.google.firbase:firebase-auth:19.3.1 – Josh Coker Mar 05 '21 at 12:20
  • 1
    @Amiya I think i got it working. found an omitted letter "com.google.firEbase.firebase-auth:19.3.1. The E was missing. thank you so much for your support and a huge thanks to Stackoverflow. Wonderful forum. – Josh Coker Mar 05 '21 at 12:33
  • 1
    How's that done please, you deserve it :) – Josh Coker Mar 05 '21 at 13:14