1

I just downloaded and installed Android Studio 3.4 and created a new project according to https://developer.android.com/training/basics/firstapp/creating-project choosing Java as language.

When the wizard was done, Gradle Sync reported the error:

ERROR: Cannot add task 'clean' as a task with that name already exists.

I found a "clean" in build.gradle and commented it out and tried to sync again resulting in the error

ERROR: The 'java' plugin has been applied, but it is not compatible with the Android plugins.

The build.gradle in the root:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()        
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0'
    }
}
allprojects {
    repositories {
        google()
        jcenter()

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

app/build.gradle:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.myapp"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

Shown above is the full content of the only build.gradle files in the project.

I tried using Kotlin as language with the same result.

Solutions to similar questions on Stackoverflow seem to involve removing apply plugin: 'java' but I don't see that here.

So I guess my question is: how did I break the Hello World wizard in Android Studio?

Jan Larsen
  • 831
  • 6
  • 13

1 Answers1

0

I deleted my $HOME/.gradle folder and now it works as expected after re-downloading gradle-wrapper. Apparently I had some old configuration in there that was messing up gradle.

Jan Larsen
  • 831
  • 6
  • 13