1

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'
// ...
1

1 Answer 1

4

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()     
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.