[go: nahoru, domu]

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

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

Closed
2 tasks done
strongville opened this issue Jun 24, 2023 · 14 comments · Fixed by #137370
Labels
a: existing-apps Integration with existing apps via the add-to-app flow P1 High-priority issues at the top of the work list platform-android Android applications specifically r: fixed Issue is closed as already fixed in a newer version t: gradle "flutter build" and "flutter run" on Android team-android Owned by Android platform team tool Affects the "flutter" command-line tool. See also t: labels. triaged-android Triaged by Android platform team

Comments

@strongville
Copy link

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.
@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Jun 26, 2023
@darshankawar
Copy link
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)

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jun 26, 2023
@strongville
Copy link
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.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jun 29, 2023
@darshankawar
Copy link
Member

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

@darshankawar darshankawar added platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels. t: gradle "flutter build" and "flutter run" on Android a: existing-apps Integration with existing apps via the add-to-app flow and removed in triage Presently being triaged by the triage team labels Jun 30, 2023
@camsim99 camsim99 added the P1 High-priority issues at the top of the work list label Jul 6, 2023
@camsim99
Copy link
Contributor
camsim99 commented Jul 6, 2023

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.

@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-android Owned by Android platform team triaged-android Triaged by Android platform team labels Jul 8, 2023
@bartekpacia
Copy link
Member

To add some more info: the problem lies in the wrongly-setup dependencies between Flutter Gradle Plugin's own Gradle tasks. The issue and comments @darshankawar linked to above are good starting points for someone to start working on it. The final result will be probably similar to #121958 (this is the PR that fixes a similar error for full-Flutter apps).

@SoftickSupport
Copy link

@strongville

This seems to be a workaround that requires amending the files generated by the Flutter SDK...

I have the same problem, so thank you so much for that workaround. It helped me with the DEBUG build.

However, there is a problem with the RELEASE build.
Android Studio's gradle project sync failed with exception
Could not get unknown property 'copyFlutterAssetsRelease' for project ':flutter' of type org.gradle.api.Project

here
afterEvaluate { bundleReleaseLocalLintAar.dependsOn copyFlutterAssetsRelease }

Unfortunately, I have no idea how to fix this. Possibly you faced the same problem?
Thanks you!

  • Android Studio Giraffe 2022.3.1
  • Gradle 8.1
  • Flutter Stable 3.13.0

@sunchangtan
Copy link
sunchangtan commented Aug 24, 2023
image flutter_home/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy

I modified the compilation script, temporarily compiled successfully

@SoftickSupport
Copy link

@sunchangtan thank you so much! it helped.

@jnstahl
Copy link
jnstahl commented Sep 12, 2023

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.
`

@SoftickSupport
Copy link

@jnstahl Use the workaround from sunchangtan. It helps.

@SoftickSupport
Copy link

@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.

@leon2017
Copy link
leon2017 commented Oct 8, 2023

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"
            }
        }
    }
}

@gmackall gmackall added P2 Important issues not at the top of the work list P1 High-priority issues at the top of the work list and removed P1 High-priority issues at the top of the work list P2 Important issues not at the top of the work list labels Oct 26, 2023
@gmackall
Copy link
Member
gmackall commented Oct 26, 2023

#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

auto-submit bot pushed a commit that referenced this issue Oct 26, 2023
Fixes #129471.

Does so by doing a very similar thing that is done by #121958, but for a task that is specific to the add to app build process.
@darshankawar darshankawar added the r: fixed Issue is closed as already fixed in a newer version label Oct 27, 2023
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: existing-apps Integration with existing apps via the add-to-app flow P1 High-priority issues at the top of the work list platform-android Android applications specifically r: fixed Issue is closed as already fixed in a newer version t: gradle "flutter build" and "flutter run" on Android team-android Owned by Android platform team tool Affects the "flutter" command-line tool. See also t: labels. triaged-android Triaged by Android platform team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants