Skip to content Skip to sidebar Skip to footer

Build.gradle File Could Not Compile

This error appears when I run my project: Could not compile build file 'H:\StartActivity\build.gradle'. startup failed: build file 'H:\StartActivity\build.gradle': 28: only builds

Solution 1:

buildscript {
    ext.kotlin_version = "1.5.0"
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.2.0"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"// NOTE: Do not place your application dependencies here; they belong// in the individual module build.gradle files
    }
}

Changing ext.kotlin_version to 1.5.0 is working :)

Solution 2:

You should move plugins{...} before allprojects{...}

// Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        ext.kotlin_version = "1.5.0-release-764"
        repositories {
            google()
            mavenCentral()
        }
        dependencies {
            classpath "com.android.tools.build:gradle:4.2.0"
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"// NOTE: Do not place your application dependencies here; they belong// in the individual module build.gradle files
        }
    }

    plugins {
        id 'org.jetbrains.kotlin.jvm' version '1.5.0-release-764'
    }
    
    allprojects {
        repositories {
            google()
            mavenCentral()
            jcenter() // Warning: this repository is going to shut down soon
        }
    }
    
....

Post a Comment for "Build.gradle File Could Not Compile"