Skip to content

Build errors with Gradle 6 #2514

Closed
Closed
@SomeTroglodyte

Description

Symptom:

Starting a debug session for the 'desktop' configuration (not affected: building android, building jar, debugging android) errors out like this:

FAILURE: Build failed with an exception.

* Where:
Initialization script '/tmp/DesktopLauncher_main__.gradle' line: 18

* What went wrong:
A problem occurred configuring project ':desktop'.
> Could not create task ':desktop:DesktopLauncher.main()'.
   > Unnecessarily replacing a task that does not exist is not supported.  Use create() or register() directly instead.  You attempted to replace a task named 'DesktopLauncher.main()', but there is no existing task with that name.

This happens even with a freshly installed Android Studio and a fresh clone as of today (taking care to clean out anything related under .git, .gradle or .config), and both on Windoze and Linux.

Cause:

This is as far as I can tell a bug in the IntelliJ IDEA up to 2019.2.x, fixed in 2019.3, but still showing in Android Studio 3.6.3 current as of today. Here is a passus: "The warning occurs because of the Run delegation feature enabled where IntelliJ IDEA generates the special Gradle code to run the project run configuration in the temp directory. This generated code triggers the warning." - of course, you need gradle <=5 for this to be only a warning.

Workaround:

Unfortunately, AS hides some IDEA options, specifically the Run delegation controls. So the only WO I'm aware of that works is going into gradle/wrapper/gradle-wrapper.properties and replace "6.2.2" with "5.6.4". Since the file is under git control, this will revert every time you switch branches. No way to have git relinquish its grip on the file without dire consequences, not that I'm aware of.

Request:

Please tell me how you deal with this. Do you not run desktop at all? Did you install IDEA 2020.1 over AS and somehow got it to not lose the Android Studio integration features? Any local workaround scripting not in the repo? Maybe a setting not visible in the UI?

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions