Yeakub Bin Aziz
Yeakub Bin Aziz

Reputation: 763

How do I fix this error: Task 'wrapper' not found in project ':app'

All my projects report this error? Is there a setting or option I need to change to resolve this error?

app: failed At 9/30/2021 2:47 PM with 1 error
   Task 'wrapper' not found in project ':app'.

Task 'wrapper' not found in project ':app'

* Try:
Run gradle tasks to get a list of available tasks.
Run with --stacktrace option to get the stack

Photo of the errors

Upvotes: 76

Views: 158357

Answers (6)

Ramesh
Ramesh

Reputation: 851

Make sure you are opening the correct folder for your project. you might have selected the root folder but your actual gradle project is in a sub folder. Select the folder that has the gradlew and gradlew.bat in it.

Upvotes: 5

Rajen Trivedi
Rajen Trivedi

Reputation: 43

For Kotlin: Here's the correct way to define the wrapper task in your build.gradle.kts file:

tasks.register<Wrapper>("wrapper") {
   gradleVersion = "5.6.4"
}

In this Kotlin DSL code, use the register function to create a new task of type Wrapper and configure its properties within the lambda block.

Note: Make sure to replace '5.6.4' with the desired version of Gradle that you want to use for your project.

Upvotes: 3

Kris B.
Kris B.

Reputation: 43

If the "unlink" option does not exist in your Gradle settings, you can manually unlink the "app" project by removing its entry from the root/.idea/gradle.xml configuration file.

Delete the .idea entry for the undesired Gradle project

Upvotes: 3

logbasex
logbasex

Reputation: 2262

enter image description here

Unlink unnecessary Gradle project and it will be fixed.

Upvotes: 27

sodino
sodino

Reputation: 461

maybe your project's structure is :


yourProjectDir:  
 --> app:  
    --> build.gradle  
 --> otherModule1:  
 --> otherModule2:  
 --> build.gradle  

The correct way to open the project is :
Click build.gradle in the root directory 'yourProjectDir', not build.gradle in the 'app' dir.

Upvotes: 36

JustinW
JustinW

Reputation: 2910

This is because your build.gradle file doesn't have a wrapper task. Add this code to build.gradle:

task wrapper(type: Wrapper){
   gradleVersion = '7.2'
}

You can replace 7.2 with the gradle version you want, then run gradle wrapper task.

Upvotes: 84

Related Questions