Skip to content
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

Missing copyFlutterAssetsDebug task dependency #701

Open
markushi opened this issue May 2, 2024 · 1 comment
Open

Missing copyFlutterAssetsDebug task dependency #701

markushi opened this issue May 2, 2024 · 1 comment
Assignees
Labels
bug Something isn't working Platform: Android

Comments

@markushi
Copy link
Member

markushi commented May 2, 2024

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.
@markushi markushi added bug Something isn't working Platform: Android labels May 2, 2024
@markushi markushi self-assigned this May 2, 2024
@markushi
Copy link
Member Author

Quick update: We're still looking into this. If you're facing this issue a downgrade to version 4.2.0 might be a viable alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Platform: Android
Projects
Status: In Progress
Development

No branches or pull requests

1 participant