Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org.gradle.execution.TaskSelectionException: Task 'wrapper' not found in project ':app'

I open my project after a few days and I started getting this error

org.gradle.execution.TaskSelectionException: Task 'wrapper' not found in project ':app'.

I tried to Clean Project and Invalidate Caches/Restart option But still no luck.

project level build.gradle:

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app level build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.seeken.pomodoro"
        minSdkVersion 17
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.recyclerview:recyclerview:1.1.0-beta04'
    implementation 'com.google.android.material:material:1.1.0-beta01'
    implementation 'org.greenrobot:greendao:3.2.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

gradle-wrapper.properties:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

I am using Android Studio 3.5.1 if it is relevant information.

like image 942
Faisal Shaikh Avatar asked Mar 27 '20 12:03

Faisal Shaikh


People also ask

Where can I find gradle wrapper?

In Android Studio, go to File > Project Structure. Then select the "project" tab on the left. Your Gradle version will be displayed here. If you are using the Gradle wrapper, then your project will have a gradle/wrapper/gradle-wrapper.

Why does gradle Sync Fail?

In some cases when your Gradle files are deleted or corrupted you will not be able to download new Gradle files in android studio. In this case, we have to delete the Gradle files which are present already and then again sync your project to download our Gradle files again.


1 Answers

What worked for me was to add this line to the project-level build.gradle (i.e. not the top-level android one, the inner app one):

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

The gradle version of course depends on what currently the latest one is.

I then got a different error message about the prepareKotlinBuildScriptModel missing and had to add this line as well:

task prepareKotlinBuildScriptModel {
}
like image 174
EboMike Avatar answered Oct 04 '22 20:10

EboMike