'buildSrc' cannot be used as a project name as it is a reserved name

12k Views Asked by At

After I upgrade my gradle gradle-5.4.1 to gradle-6.3, I got an error like 'buildSrc' cannot be used as a project name as it is a reserved name. I'm using buidleSrc for Gradle Dependency Management(link). I dont know how to solve this issue please help on this.

enter image description here

4

There are 4 best solutions below

0
On

This is mentioned in #2 of the answer from HBB20, but I didn't catch it my first few times: Also remove references to buildSrc from all your modules, for example this line:

implementation(project(":buildSrc"))
0
On

just remove include ':buildSrc' from the settings.gradle file and everything will go well.

1
On

This is a change introduced in Gradle 6.0 that made buildSrc a reserved project name.

It means you have a reference to buildSrc as a project in your settings.gradle(.kts). The reference will look like:

  • include("buildSrc")
  • includeBuild("buildSrc")

I would recommend to start by removing that reference and see if it fixes the issue. If not, it means your project was wired differently and you simply have to rename it.

1
On

tldr: Remove "buildSrc" from settings.gradle / settings.gradle.kts. With gradle update, "buildSrc" is now reserved project name.

If you are looking an answer for Android, this should be helpful:

  1. Open your settings.gradle / settings.gradle.kts
  2. Remove "buildSrc" from included modules
  3. Rebuild

Example:

settings.gradle.kts might look like this (syntax will be different for settings.gradle)

include(":app")
rootProject.name = "yourapp"
include(":moduleA")
include(":buildSrc")
include(":moduleB")
include(":moduleC")

remove the line that includes "buildSrc" like:

include(":app")
rootProject.name = "yourapp"
include(":moduleA")
include(":moduleB")
include(":moduleC")

and rebuild project.