getsentry / sentry-android-gradle-plugin

Gradle plugin for Sentry Android. Upload proguard, debug files, and more.

Home Page:https://docs.sentry.io/platforms/android/gradle/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing copyFlutterAssetsDebug task dependency

markushi opened this issue · comments

Description

Flutter registers it's own copyAssets task, which get's wired up with the mergeAssets task here: https://github.com/flutter/flutter/blob/6ce591f7ea3ba827d9340ce03f7d8e3a37ebb03a/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy#L1295-L1298

Our plugin on the other hand uses assets transformer to inject the properties file:

// we can't hook into asset generation, nor manifest merging, as all those tasks
// are dependencies of the compilation / minification task
// and as our ProGuard UUID depends on minification itself; creating a
// circular dependency
// instead, we transform all assets and inject the properties file
sentryVariant?.assetsWiredWithDirectories(
InjectSentryMetaPropertiesIntoAssetsTask.register(
project,
extension,
sentryTelemetryProvider,
tasksGeneratingProperties,
variant.name.capitalized
),
InjectSentryMetaPropertiesIntoAssetsTask::inputDir,
InjectSentryMetaPropertiesIntoAssetsTask::outputDir
)

The transformer is used to avoid any tasks dependencies, as copyFlutterAssets is hooked up in a way that it depends on the minify task, which is a required input for our task, leading to circular dependencies, see this related issue for more details: getsentry/sentry-react-native#3644

Steps to reproduce:

  1. setup a blank flutter app
  2. setup sentry
  3. setup assets for the flutter app via pubspec.yaml
  assets:
    - some/random/file.png
  1. Try to build the app, it fails with the following error message:
FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':app:injectSentryDebugMetaPropertiesIntoAssetsDebug' (type 'InjectSentryMetaPropertiesIntoAssetsTask').
  - Gradle detected a problem with the following location: '<app>/build/app/intermediates/assets/debug/mergeDebugAssets'.
    
    Reason: Task ':app:injectSentryDebugMetaPropertiesIntoAssetsDebug' uses this output of task ':app:copyFlutterAssetsDebug' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':app:copyFlutterAssetsDebug' as an input of ':app:injectSentryDebugMetaPropertiesIntoAssetsDebug'.
      5. Declare an explicit dependency on ':app:copyFlutterAssetsDebug' from ':app:injectSentryDebugMetaPropertiesIntoAssetsDebug' using Task#dependsOn.
      6. Declare an explicit dependency on ':app:copyFlutterAssetsDebug' from ':app:injectSentryDebugMetaPropertiesIntoAssetsDebug' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.2/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.