Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Error - Failed to calculate the value of property 'extraGeneratedResDir' in Android Studio

I am running a simple app using Firebase database in Android Studio - have set up the project on the Firebase dashboard and connected into my Android Studio app. When building the project I am getting this error:

Execution failed for task ':app:mapDebugSourceSetPaths'.
> Error while evaluating property 'extraGeneratedResDir' of task ':app:mapDebugSourceSetPaths'
   > Failed to calculate the value of task ':app:mapDebugSourceSetPaths' property 'extraGeneratedResDir'.
      > Querying the mapped value of provider(java.util.Set) before task ':app:processDebugGoogleServices' has completed is not supported

Here is the stack trace:

Executing tasks: [:app:assembleDebug] in project D:\work\Android Studio\FirebaseExample2

    Download https://plugins.gradle.org/m2/com/gradle/gradle-enterprise-gradle-plugin/3.10.2/gradle-enterprise-gradle-plugin-3.10.2.jar, took 1 s 705 ms (2.21 MB)
    > Task :app:createDebugVariantModel
    > Task :app:preBuild UP-TO-DATE
    > Task :app:preDebugBuild UP-TO-DATE
    > Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
    > Task :app:compileDebugAidl NO-SOURCE
    > Task :app:compileDebugRenderscript NO-SOURCE
    > Task :app:generateDebugBuildConfig
    > Task :app:javaPreCompileDebug
    > Task :app:checkDebugAarMetadata
    > Task :app:generateDebugResValues
    > Task :app:mapDebugSourceSetPaths FAILED
    > Task :app:generateDebugResources
    > Task :app:mergeDebugResources
    > Task :app:processDebugGoogleServices
    Execution optimizations have been disabled for task ':app:processDebugGoogleServices' to ensure correctness due to the following reasons:
      - Gradle detected a problem with the following location: 'D:\work\Android Studio\FirebaseExample2\app\build\generated\res\google-services\debug'. Reason: Task ':app:mergeDebugResources' uses this output of task ':app:processDebugGoogleServices' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.5/userguide/validation_problems.html#implicit_dependency for more details about this problem.
    > Task :app:packageDebugResources
    > Task :app:createDebugCompatibleScreenManifests
    > Task :app:extractDeepLinksDebug
    > Task :app:parseDebugLocalResources
    > Task :app:processDebugMainManifest
    > Task :app:processDebugManifest
    > Task :app:mergeDebugShaders
    > Task :app:compileDebugShaders NO-SOURCE
    > Task :app:generateDebugAssets UP-TO-DATE
    > Task :app:mergeDebugAssets
    > Task :app:compressDebugAssets
    > Task :app:processDebugJavaRes NO-SOURCE
    > Task :app:desugarDebugFileDependencies
    > Task :app:checkDebugDuplicateClasses
    > Task :app:mergeDebugJniLibFolders
    > Task :app:processDebugManifestForPackage
    > Task :app:mergeDebugJavaResource
    > Task :app:mergeExtDexDebug

Here is google-services.json (downloaded from Firebase console and pasted into the app directory here (D:\work\Android Studio\FirebaseExample2\app): directory location for google-services.json file

{
  "project_info": {
    "project_number": "102836682558",
    "firebase_url": "https://example-d3da6-default-rtdb.firebaseio.com",
    "project_id": "example-d3da6",
    "storage_bucket": "example-d3da6.appspot.com"
  },
  "client": [
    {
      "client_info": {
        "mobilesdk_app_id": "1:102836682558:android:b20556c6763de16c5c766f",
        "android_client_info": {
          "package_name": "com.enetapplications.firebaseexample"
        }
      },
      "oauth_client": [
        {
          "client_id": "102836682558-j851bq7699ovchhcufcn1o60jul1fpm3.apps.googleusercontent.com",
          "client_type": 1,
          "android_info": {
            "package_name": "com.enetapplications.firebaseexample",
            "certificate_hash": "1dad8469cb2080d8e92693b394b0791456170041"
          }
        },
        {
          "client_id": "102836682558-9rgt5a9e3s1305joulfhpugrjhdrpm7v.apps.googleusercontent.com",
          "client_type": 3
        }
      ],
      "api_key": [
        {
          "current_key": "AIzaSyCKFtgpzJ7ITDeC8LBIysH1B5PyKjOrXJc"
        }
      ],
      "services": {
        "appinvite_service": {
          "other_platform_oauth_client": [
            {
              "client_id": "102836682558-9rgt5a9e3s1305joulfhpugrjhdrpm7v.apps.googleusercontent.com",
              "client_type": 3
            }
          ]
        }
      }
    }
  ],
  "configuration_version": "1"
}

Here is build.gradle:

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

android {
    namespace 'com.enetapplications.firebaseexample'
    compileSdkVersion 33

    defaultConfig {
        applicationId "com.enetapplications.firebaseexample"
        minSdkVersion 27
        targetSdkVersion 33
        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:1.6.1'
    implementation 'com.google.android.material:material:1.9.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'com.google.firebase:firebase-database:20.0.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

Lastly here is MainActivity.java:

package com.enetapplications.firebaseexample;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

public class MainActivity extends AppCompatActivity {

    Button send;
    EditText name;

    FirebaseDatabase database = FirebaseDatabase.getInstance();
    DatabaseReference reference = database.getReference().child("users");

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        name = findViewById(R.id.editText);
        send = findViewById(R.id.button);

        send.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String userName = name.getText().toString();
                reference.child("userName").setValue(userName);
            }
        });

    }
}

I have already tried invalidating caches and restarting Android Studio, but the issue persists.

Thank you!!!

like image 432
kiteandwindsurfer Avatar asked Sep 11 '25 03:09

kiteandwindsurfer


1 Answers

Found the problem, was in the build.gradle (Project: ) file, specifically this line:

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

needed to be changed to:

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

So the entire gradle file now is:

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:4.3.15'
    }
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.4.0' apply false
    id 'com.android.library' version '7.4.0' apply false
}

This will undoubtedly change as new releases come down the pike but as of June 28, 2023 my program is compiling perfectly!

like image 144
kiteandwindsurfer Avatar answered Sep 12 '25 16:09

kiteandwindsurfer