Skip to content

:app:uploadCrashlyticsMappingFileRelease build task fails after upgrading to crashlytics plugin version 3.0.1 #5962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SkillsDelivery opened this issue May 14, 2024 · 16 comments
Assignees
Labels
api: crashlytics type: bug Something isn't working

Comments

@SkillsDelivery
Copy link

SkillsDelivery commented May 14, 2024

Environment:

  • Android Studio version: Jellyfish (2023.3.1)
  • Firebase Component: Crashlytics
  • Component version: 3.0.1

Problem description:

I just upgraded the version of "com.google.firebase.crashlytics" plugin from "2.9.9" to "3.0.1" and the build started to fail.
Here is the build command which is failing:

./gradlew --parallel assemble

The build succeeds if I build only one build type at a time by running either

./gradlew --parallel assembleDebug

or

./gradlew --parallel assembleRelease

Logs:

> Task :app:uploadCrashlyticsMappingFileRelease FAILED
...
FAILURE: Build failed with an exception.
...
* What went wrong:
A problem was found with the configuration of task ':app:uploadCrashlyticsMappingFileRelease' (type 'UploadMappingFileTask').
  - Gradle detected a problem with the following location: 'C:\dev\coffee-beans\projects\quick-list-app\app\build\gmpAppId.txt'.

    Reason: Task ':app:uploadCrashlyticsMappingFileRelease' uses this output of task ':app:processDebugGoogleServices' without declaring an explicit or implicit dependency. This can lead to incorrect results being produc
ed, depending on what order the tasks are executed.

    Possible solutions:
      1. Declare task ':app:processDebugGoogleServices' as an input of ':app:uploadCrashlyticsMappingFileRelease'.
      2. Declare an explicit dependency on ':app:processDebugGoogleServices' from ':app:uploadCrashlyticsMappingFileRelease' using Task#dependsOn.
      3. Declare an explicit dependency on ':app:processDebugGoogleServices' from ':app:uploadCrashlyticsMappingFileRelease' using Task#mustRunAfter.

    For more information, please refer to https://docs.gradle.org/8.7/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

Relevant Code:

"com.google.gms.google-services" version: "4.4.1"
"com.google.firebase:firebase-bom" version: "33.0.0"

Relevant parts of my app/build.gradle.kts file:

plugins {
    ...
    alias(libs.plugins.google.services)
    alias(libs.plugins.firebase.crashlytics)
   ...
}

android {
    ...
   buildTypes {
        debug {
            isDebuggable = true
            isMinifyEnabled = false
            manifestPlaceholders["crashlyticsCollectionEnabled"] = "false"
            configure<CrashlyticsExtension> { mappingFileUploadEnabled = false }
        }
        release {
            isDebuggable = false
            isMinifyEnabled = true
            proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
            manifestPlaceholders["crashlyticsCollectionEnabled"] = "true"
            configure<CrashlyticsExtension> { mappingFileUploadEnabled = true }
        }
    }
}
...

Relevant parts of my AndroidManifest.xml file:

    <application ...>
        ...
        <meta-data
            android:name="firebase_crashlytics_collection_enabled"
            android:value="${crashlyticsCollectionEnabled}" />
        ...
    </application>

Releavant parts of my proguard-rules.pro file:

...
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
@michaelaubertcmc
Copy link

michaelaubertcmc commented May 14, 2024

I have the same issue

:app:uploadCrashlyticsMappingFileVariant1BuildType1 uses this output of task ':app:processVariant2BuildType1GoogleServices' without declaring an explicit or implicit dependency

(notice the different variants)

But that happened while running gradle tasks without variants.

So: gradlew app:bundleBuildType1 fails but gradlew app:bundleVariant1BuildType1 and gradlew app:bundleVariant2BuildType1 both work fine.

@lehcar09
Copy link
Contributor

Hi @SkillsDelivery, thank you for reaching out. I was able to reproduce the issue. I'll notify our engineers and see what we can do here. Hang tight!

@lehcar09 lehcar09 added the type: bug Something isn't working label May 14, 2024
@vullnetlimani
Copy link

Same here as well.

We're encountering a recurring issue where the builds complete successfully, but towards the end, we encounter an error related to the Gradle task :app:uploadCrashlyticsMappingFileDevRelease. The specific problem identified by Gradle pertains to the location of a file at 'projectPath\app\build\gmpAppId.txt'

With 2.9.9 no prob.

@mrober
Copy link
Contributor

mrober commented May 14, 2024

Thanks for the reports and the output. The issue is the google-services plugin is outputting a file that Crashlytics consumes, but this file is getting clobbered when building multiple variants in a single build. I will fix this in google-services, then simply updating that plugin will resolve this issue.

For now, I have come up with a workaround you can do in your build.gradle.ktx file:

import com.google.gms.googleservices.GoogleServicesTask

project.afterEvaluate {
  tasks.withType<GoogleServicesTask> {
    gmpAppId.set(project.buildDir.resolve("$name-gmpAppId.txt"))
  }
}

dependencies {
  compileOnly("com.google.gms:google-services:4.4.1")
}

I will update this issue when the fix is released.

@penkzhou
Copy link

penkzhou commented May 16, 2024

Thanks for the reports and the output. The issue is the google-services plugin is outputting a file that Crashlytics consumes, but this file is getting clobbered when building multiple variants in a single build. I will fix this in google-services, then simply updating that plugin will resolve this issue.

For now, I have come up with a workaround you can do in your build.gradle.ktx file:

import com.google.gms.googleservices.GoogleServicesTask

project.afterEvaluate {
  tasks.withType<GoogleServicesTask> {
    gmpAppId.set(project.buildDir.resolve("$name-gmpAppId.txt"))
  }
}

dependencies {
  compileOnly("com.google.gms:google-services:4.4.1")
}

I will update this issue when the fix is released.

That works.If you use build.gradle,the workaround can be:

import com.google.gms.googleservices.GoogleServicesTask

project.afterEvaluate {
  tasks.withType(GoogleServicesTask).configureEach {
    gmpAppId.set(new File(project.buildDir, "${name}-gmpAppId.txt"))
  }
}

dependencies {
  compileOnly("com.google.gms:google-services:4.4.1")
}

@Philio
Copy link

Philio commented May 17, 2024

Thanks for the workaround @mrober, buildDir is deprecated, this small tweak worked:

project.afterEvaluate {
    tasks.withType<GoogleServicesTask> {
        gmpAppId.set(project.layout.buildDirectory.file("$name-gmpAppId.txt"))
    }
}

@diareuse
Copy link

If anybody wants to do this in Groovy

afterEvaluate {
    tasks.withType(com.google.gms.googleservices.GoogleServicesTask).configureEach {
        gmpAppId.set(layout.buildDirectory.file("$name-gmpAppId.txt"))
    }
}

@tprochazka
Copy link

The last working version of com.google.gms.google-services for me is 4.3.15, everything later was somehow broken related to Firebase functionality. I don't understand why it is so badly maintained, almost dead project, together with ever more read oss-licenses-plugin :-(. Why it is not part of the Firebase libraries ecosystem?

@michaelaubertcmc
Copy link

@tprochazka well, when a company lays off thousands of engineers, things move slower.

We now live in a world where the stock market measures perceived suffering instead of perceived value.

We have to suffer to make the investors happy. I don't like it either.

I'm sorry. I try to leave this stuff out of GitHub but you were wondering why this is happening.

@tprochazka
Copy link

@tprochazka Ohh :-( the same in our company. I hope that it is better in Google.

@thatfiredev
Copy link
Member

Hey all, the version of google-services plugin that contains the fix for this issue (4.4.2) has been released: https://firebase.google.com/support/release-notes/android#google-services_plugin_v4-4-2

@aantonic
Copy link

aantonic commented Jun 3, 2024

I've upgraded google-service to 4.4.2, and it still fails

Uploading mapping file '/Users/runner/work/1/s/mobile/android/app/build/protected/bundle/flavorRelease/ProGuardMappingFile.txt' to Crashlytics

Task :app:protectAabFlavorRelease FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:protectAabFlavorRelease'.

'void com.google.firebase.crashlytics.buildtools.gradle.tasks.UploadMappingFileTask.setMappingFileProvider(org.gradle.api.provider.Provider)'

@mrober
Copy link
Contributor

mrober commented Jun 3, 2024

@aantonic can you please run that task again with --stacktrace?

@aantonic
Copy link

aantonic commented Jun 4, 2024

It seems binary/source compatibility has been broken:
(ai.digital.protectandroid is third-party component used for app protection)

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:protectAabFlavorRelease'.

Caused by: java.lang.NoSuchMethodError: 'void com.google.firebase.crashlytics.buildtools.gradle.tasks.UploadMappingFileTask.setMappingFileProvider(org.gradle.api.provider.Provider)'
at ai.digital.protectandroid.protection.crashlytics.CrashlyticsMappingFileUploader.uploadMappingFile(CrashlyticsMappingFileUploader.kt:37)
at ai.digital.protectandroid.protection.tasks.AppProtectionTask.applyProtection(AppProtectionTask.kt:90)
at ai.digital.protectandroid.protection.tasks.AppProtectionTask.protectAab(AppProtectionTask.kt:75)
at ai.digital.protectandroid.protection.tasks.AppProtectionTask.runProtection(AppProtectionTask.kt:26)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:125)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:58)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:51)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:29)
at org.gradle.api.internal.tasks.execution.TaskExecution$3.run(TaskExecution.java:248)

@mrober
Copy link
Contributor

mrober commented Jun 4, 2024

I am not sure about ai.digital.protectandroid.protection.crashlytics sorry. It looks like they rely on implementation details, not the public api, of the Crashlytics Gradle plugin. And after v3, the implementation is entirely different.

The v3 of the Crashlytics plugin gets the merged mapping file from AGP via SingleArtifact.OBFUSCATION_MAPPING_FILE. There is likely no need for this tool to call the Crashlytics plugin directly like that to set the mapping file.

This is an issue you can file with them. I am closing this one since the issue is with them. But feel free to reference this issue, and I don't mind providing them with any information if they need it.

@mrober mrober closed this as completed Jun 4, 2024
@SkillsDelivery
Copy link
Author

I upgraded crashlytics plugin to 3.0.1 and google-service plugin to 4.4.2 and now I could build with no problems. Everything seems to be fine now.

Thank you so much, guys! <3

@firebase firebase locked and limited conversation to collaborators Jul 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: crashlytics type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests