sentry-android-gradle-plugin icon indicating copy to clipboard operation
sentry-android-gradle-plugin copied to clipboard

Missing copyFlutterAssetsDebug task dependency

Open markushi opened this issue 1 year ago • 0 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: https://github.com/getsentry/sentry-android-gradle-plugin/blob/6d1c33d8abb76186e25dd7f6c9f0bcfdf65aee5d/plugin-build/src/main/kotlin/io/sentry/android/gradle/AndroidComponentsConfig.kt#L124-L139

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: https://github.com/getsentry/sentry-react-native/issues/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.

markushi avatar May 02 '24 06:05 markushi