the_prole
the_prole

Reputation: 8985

Could not find method classpath() for arguments [com.android.tools.build:gradle:3.4.2]

This is my build.gradle file

apply plugin: 'java'

repositories {
    jcenter()
    google()
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
    }
}

dependencies {
    // The production code uses the SLF4J logging API at compile time
    compile 'org.slf4j:slf4j-api:1.7.25'
    testCompile 'junit:junit:4.12'
}

This is the error I get when I run gradle build

Could not find method classpath() for arguments [com.android.tools.build:gradle:3.4.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

I have multi module project, here is my settings.gradle

include 'module-1'
include 'module-2'
include 'module-3'
include 'module-4:java'
include 'module-5'

rootProject.name = 'my-root-project'

What I am trying to do is have sub module use plugin com.android.application; here is build.gradle for plugin1 which is Android app project

apply plugin: 'com.android.application'
// ...

Upvotes: 1

Views: 6597

Answers (1)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 365028

You have to move the dependencies block out of repositories block:

dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
    }

Something like that:

buildscript {    
    repositories {
        google()
        jcenter()        
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        //...
}

allprojects {
    repositories {
        google()
        jcenter()     
    }
}

Upvotes: 4

Related Questions