Could not find method compile() for arguments

Hi, I have a multi-project build, the root build.gradle defines these repositories for all subprojects:

allprojects {
    // repositories for all sub-projects
  repositories {
    // local checked in maven repo has 3rd party jars not available in maven central
    maven { url "${rootProject.projectDir}/chromium/.m2" }
      // sonatype central
    maven { url "" }

One particular subproject is called base. It is using Google’s android-library plugin

apply plugin: 'android-library'

The plugin is configured in the root build.gradle – all subprojects are mostly the same, so they are configured in the root, and the only thing that differs in each of their respective build.gradle files is the dependencies section. So the base project build.gradle looks like this:

// print the known repositories so we can sanity check the problem
repositories.each { repo ->
  println "repository: " + repo.url
  dependencies {
  // pulled from project local .m2/repository
  compile "javax.annotations:jsr305:1.0"

When I go to build this project, I get the following error:

davis@mbp:~/git/browser-framework/chromium/base$gradle build
repository: file:/Users/davis/git/browser-framework/chromium/.m2/
  FAILURE: Build failed with an exception.
  * Where:
Build file '/Users/davis/git/browser-framework/chromium/base/build.gradle' line: 20
  * What went wrong:
A problem occurred evaluating project ':chromium:base'.
> Could not find method compile() for arguments [javax.annotations:jsr305:1.0] on project ':chromium:base'.
  * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  Total time: 1 mins 4.31 secs

I do have a local file .m2 repository embedded in the project directory structure. This is because these jars are unavailable in a public maven/ivy repo, and I do not have a local maven repo server set up right now. Also, there’s a bug in the android-gradle plugin that prevents me from adding these as simple file or flatDir based dependencies. To sanity check, the jar it is trying to depend on does exist in the right place, and you can see in the printout above that it is pointing to the correct location for that repository:

davis@mbp:~/git/browser-framework$ls -al /Users/davis/git/browser-framework/chromium/.m2/javax/annotations/jsr305/1.0/
total 72
5 davis
  170 Oct 29 10:16 .
4 davis
  136 Oct 29 10:16 ..
1 davis
  160 Oct 29 10:16 _maven.repositories
1 davis
27210 Oct 29 10:16 jsr305-1.0.jar
1 davis
  465 Oct 29 10:16 jsr305-1.0.pom

This just indicates that the jar is available in the correct location that it should be expecting.

I think the problem is more fundamental, however – since it is complaining that it cannot find the method compile() it seems there may be something structurally awry with the build.

I’m looking for some pointers on the best way to debug this or quick tips on how to resolve?

The build is somewhat complex, and I have had this structure working before - but I have not encountered this particular compile problem.

The ‘compile’ configuration is only available after you have applied a plugin such as ‘android-library’.

Thanks, turns out I had a stupid error in my script that was causing the plugin to not be applied, like you said.