firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.7k stars 3.97k forks source link

Build fails with: Execution failed for task ':app:mapDebugSourceSetPaths'. #8238

Closed TobiasLenzEconix closed 2 years ago

TobiasLenzEconix commented 2 years ago

Bug report

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(interface java.util.Set) before task ':app:processDebugGoogleServices' has completed is not supported

flutter build appbundle

Steps to reproduce

Steps to reproduce the behavior:

android/app/build.gradle:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion flutter.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId ".."
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.google.firebase:firebase-messaging:21.0.1'
}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

android/build.gradle:

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3+'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
         // Add the google services classpath
        classpath 'com.google.gms:google-services:+'

    }

}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Expected behavior

The build fails with the above error message.

Additional context

Add any other context about the problem here.


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` [✓] Flutter (Channel stable, 2.10.3, on macOS 12.2.1 21D62 darwin-arm, locale en-DE) [✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1) [✓] Chrome - develop for the web [!] Android Studio (not installed) [✓] IntelliJ IDEA Community Edition (version 2021.3.1) [✓] VS Code (version 1.65.0) [✓] Connected device (2 available) [✓] HTTP Host Availability ```

Flutter dependencies

Run `Dart SDK 2.16.1 Flutter SDK 2.10.3 AppName 1.0.5+36

dependencies:

dev dependencies:

transitive dependencies:

Click To Expand ``` PASTE OUTPUT INSIDE HERE ```

darshankawar commented 2 years ago

Looking at the error, it doesn't seem to be related to flutterfire, so closing from here. Also as a note, when you open an issue, please use new issue template and fill out requested details so that we'll have enough details to work with.

If you think the issue you are getting is due to flutterfire plugin, write in comments, fill out template and we'll address it.

TobiasLenzEconix commented 2 years ago

What do you mean?

I used the template and files ind all the flutter doctor command output. If I uncomment the last line:

// ADD THIS AT THE BOTTOM apply plugin: 'com.google.gms.google-services'

the build succeeds

muhammadyusuf-kurbonov commented 2 years ago

Have anyone solved this problem? It seems google-services is using deprecated (and removed) feature of gradle

TobiasLenzEconix commented 2 years ago

@muhammadyusuf-kurbonov I somehow fixed it. But I am not sure what did the trick. I think in firebase changed the instructions for android.

e.g. no you need no use implementation platform('com.google.firebase:firebase-bom:29.2.1')

instead of:

implementation 'com.google.firebase:firebase-messaging:21.0.1'

but see the whole Firebase Android instruction for details.

Its a shame that no one tells you about the api changes...

muhammadyusuf-kurbonov commented 2 years ago

Thank you. I will check 👍👍👍

freindlytech commented 2 years ago

I am also facing this issue anybody know how to fix it ? I am getting this issue only if I use agp 7.3.0-alpha07 and a project with firebase implemented otherwise if I use previous ago like 7.3.0-alpha03 then I didn't face this error. Here is the screenshot

Screenshot_20220323-015627

freindlytech commented 2 years ago

@muhammadyusuf-kurbonov I somehow fixed it. But I am not sure what did the trick. I think in firebase changed the instructions for android.

e.g. no you need no use implementation platform('com.google.firebase:firebase-bom:29.2.1')

instead of:

implementation 'com.google.firebase:firebase-messaging:21.0.1'

but see the whole Firebase Android instruction for details.

Its a shame that no one tells you about the api changes...

It didn't work for me

JensLeirens commented 2 years ago

I also had this kind of error with my project. after some reverting back changes i noticed the error only came when using the 'com.google.gms:google-services:4.3.10' dependency. after changing back the google service version to 4.3.5 the error was resolved.

I hope this helps

muhammadyusuf-kurbonov commented 2 years ago

I also had this kind of error with my project. after some reverting back changes i noticed the error only came when using the 'com.google.gms:google-services:4.3.10' dependency. after changing back the google service version to 4.3.5 the error was resolved.

I hope this helps

THANK YOU! It works!