Skip to content

WorkValidationException on add-to-app project for task ':flutter:copyFlutterAssetsRelease' on Gradle 8.1 and AGP 8.0 #129471

Description

@strongville

Is there an existing issue for this?

Steps to reproduce

Start compiling app (task :app:assembleRelease)

  • Flutter Stable 3.10.5
  • AGP 8.0.1
  • Gradle 8.1
  • Add-to-app module (named ':flutter' on logs)
  • Java 17
  • Android Studio Giraffe 2022.3.1 RC 1

Expected results

Build succeeds and app is installed on device.

Actual results

Build fails on task :flutter:copyFlutterAssetsRelease, after finishing all other native tasks for the project.
Screenshot below shows the tasks with warnings or failures for the current build.

Code sample

This issue is not related with Dart code.

Screenshots or Video

Screenshots / Video demonstration

List of failed/with warning tasks
Latest tasks executed

Logs

Logs
FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':flutter:copyFlutterAssetsRelease' (type 'Copy').
  - Gradle detected a problem with the following location: '/home/strongville/[...]/flutter/.android/Flutter/build/intermediates/library_assets/release/out'.
    
    Reason: Task ':flutter:bundleReleaseLocalLintAar' uses this output of task ':flutter:copyFlutterAssetsRelease' 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 ':flutter:copyFlutterAssetsRelease' as an input of ':flutter:bundleReleaseLocalLintAar'.
      2. Declare an explicit dependency on ':flutter:copyFlutterAssetsRelease' from ':flutter:bundleReleaseLocalLintAar' using Task#dependsOn.
      3. Declare an explicit dependency on ':flutter:copyFlutterAssetsRelease' from ':flutter:bundleReleaseLocalLintAar' using Task#mustRunAfter.
    
    Please refer to https://docs.gradle.org/8.1/userguide/validation_problems.html#implicit_dependency for more details about this problem.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/8.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1m 27s
208 actionable tasks: 56 executed, 1 from cache, 151 up-to-date

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.10.5, on KDE neon 5.27 5.19.0-45-generic, locale es_MX.UTF-8)
    • Flutter version 3.10.5 on channel stable at /opt/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 796c8ef792 (10 days ago), 2023-06-13 15:51:02 -0700
    • Engine revision 45f6e00911
    • Dart version 3.0.5
    • DevTools version 2.23.1

[!] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /home/strongville/Android/Sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✗] Linux toolchain - develop for Linux desktop
    ✗ clang++ is required for Linux development.
      It is likely available from your distribution (e.g.: apt install clang), or can be downloaded from
      https://releases.llvm.org/
    ✗ CMake is required for Linux development.
      It is likely available from your distribution (e.g.: apt install cmake), or can be downloaded from
      https://cmake.org/download/
    ✗ ninja is required for Linux development.
      It is likely available from your distribution (e.g.: apt install ninja-build), or can be downloaded from
      https://github.com/ninja-build/ninja/releases
    • pkg-config version 0.29.2
    ✗ GTK 3.0 development libraries are required for Linux development.
      They are likely available from your distribution (e.g.: apt install libgtk-3-dev)

[✓] Android Studio (version 2022.3)
    • Android Studio at
      /home/strongville/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/223.8836.35.2231.10271316
    • Flutter plugin version 74.0.3
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] Android Studio (version 2022.3)
    • Android Studio at
      /home/strongville/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/223.8836.35.2231.10320515
    • Flutter plugin version 74.0.3
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[!] Android Studio (version 2023.1)
    • Android Studio at
      /home/strongville/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-1/231.9011.34.2311.10335024
    • Flutter plugin version 74.0.4
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

[✓] VS Code (version 1.79.2)
    • VS Code at /usr/share/code
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (2 available)
    • SM A207M (mobile) • R9TMB02DK0J • android-arm64 • Android 11 (API 30)
    • Linux (desktop)   • linux       • linux-x64     • KDE neon 5.27 5.19.0-45-generic

[✓] Network resources
    • All expected network resources are available.

Activity

  1. darshankawar commented on Jun 26, 2023

    @darshankawar
    Member

    Thanks for the report.
    Can you take a look at below links and see if they help in your case ?

    #117043
    #117043 (comment)
    #117043 (comment)

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 26, 2023
  3. strongville commented on Jun 29, 2023

    @strongville
    Author

    This seems to be a workaround that requires amending the files generated by the Flutter SDK (same files that shouldn't be added to version control), is this correct?

    These lines were added to .android/Flutter/build.gradle:

    afterEvaluate {
        bundleDebugLocalLintAar.dependsOn copyFlutterAssetsDebug
        bundleReleaseLocalLintAar.dependsOn copyFlutterAssetsRelease
    }
    

    This solves the exception previously shown above. Is there a way for this to be included by default when generating files on Flutter SDK? I see the referred comment was posted several months ago, is there a blocking issue or major refactor awaiting?

    Personally, I'd like to depend on as less workarounds as possible, to be able that the team members can configure the project more easily.

    Also, to be able to use AGP 8.0 we require Gradle 8, so, for this case, downgrading Gradle versions to the one where this is a warning instead of an exception, isn't a choice either, unfortunately.

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 29, 2023
  5. darshankawar commented on Jun 30, 2023

    @darshankawar
    Member

    Thanks for the update. Keeping this issue open based on the error received and above feedback.

  6. added
    platform-androidAndroid applications specifically
    toolAffects the "flutter" command-line tool. See also t: labels.
    t: gradle"flutter build" and "flutter run" on Android
    a: existing-appsIntegration with existing apps via the add-to-app flow
    and removed
    in triagePresently being triaged by the triage team
    on Jun 30, 2023
  7. added
    P1High-priority issues at the top of the work list
    on Jul 6, 2023
  8. camsim99 commented on Jul 6, 2023

    @camsim99
    Contributor

    To whoever takes this bug: this is probably a problem we have with other tasks. When fixing this bug, identify anything in the code that can allow us to audit the rest of our code for similar problems.

  9. 4 remaining items

  10. SoftickSupport commented on Sep 4, 2023

    @SoftickSupport

    @sunchangtan thank you so much! it helped.

  11. jnstahl commented on Sep 12, 2023

    @jnstahl

    This seems to be a workaround that requires amending the files generated by the Flutter SDK (same files that > These lines were added to .android/Flutter/build.gradle:

    afterEvaluate {
        bundleDebugLocalLintAar.dependsOn copyFlutterAssetsDebug
        bundleReleaseLocalLintAar.dependsOn copyFlutterAssetsRelease
    }
    

    Where exactly does this go? I tried adding this to my build.gradle as a workaround but I get this error

    `A problem occurred configuring root project 'Timing'.

    A problem occurred configuring project ':flutter'.
    Could not get unknown property 'copyFlutterAssetsDebug' for extension 'flutter' of type FlutterExtension.
    `

  12. SoftickSupport commented on Sep 18, 2023

    @SoftickSupport

    @jnstahl Use the workaround from sunchangtan. It helps.

  13. SoftickSupport commented on Sep 30, 2023

    @SoftickSupport

    @sunchangtan @jnstahl
    I added the double quotes to the original workaround:

    afterEvaluate {
        bundleDebugLocalLintAar.dependsOn "copyFlutterAssetsDebug"
        bundleReleaseLocalLintAar.dependsOn "copyFlutterAssetsRelease"
    }
    

    Now, I don't need to change Flutter sources.
    Unfortunately, the double quotes only helped me with my Jenkins (Linux) build.
    I still need to change Flutter sources on my Windows work PC.

    I hope this will be helpful.

  14. leon2017 commented on Oct 8, 2023

    @leon2017

    project build.gradle add this:

    subprojects { sub ->
        sub.afterEvaluate { proj ->
            if (proj.name == 'flutter') {
                def flutterProject = project(':flutter')
                flutterProject.afterEvaluate {
                    bundleDebugLocalLintAar.dependsOn "copyFlutterAssetsDebug"
                    bundleReleaseLocalLintAar.dependsOn "copyFlutterAssetsRelease"
                }
            }
        }
    }
    
  15. added
    P2Important issues not at the top of the work list
    P1High-priority issues at the top of the work list
    and removed
    P1High-priority issues at the top of the work list
    P2Important issues not at the top of the work list
    on Oct 26, 2023
  16. gmackall commented on Oct 26, 2023

    @gmackall
    Member

    #137370 should land shortly, and fixed this issue in my local reproduction. There are multiple workflows to run add to app projects though, so please let me know if it doesn't fix it for you

  17. added
    r: fixedIssue is closed as already fixed in a newer version
    on Oct 27, 2023
  18. github-actions commented on Nov 13, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  19. locked as resolved and limited conversation to collaborators on Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work lista: existing-appsIntegration with existing apps via the add-to-app flowplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versiont: gradle"flutter build" and "flutter run" on Androidteam-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions