Gradle Could not find method compile() for arguments
<p>i have a hello world full screen android studio 1.5.1 app that i added a gradle/eclipse-mars subproject to. no other files were modified except for adding include ':javalib' to settings.gradle. adding a <a href="https://docs.gradle.org/current/userguide/multi_project_builds.html#sec:project_jar_dependencies" rel="noreferrer">project lib dependency</a>:</p>

<pre><code>project(':app') {
    dependencies {
        compile project(':javalib') // line 23
    }
}
</code></pre>

<p>to the root build build file and running gradle from the command line , gets:</p>

<ul>
<li><p>Where:
Build file 'D:\AndroidStudioProjects\AndroidMain\build.gradle' line: 23</p></li>
<li><p>What went wrong:
A problem occurred evaluating root project 'AndroidMain'.</p>

<blockquote>
  <p>Could not find method compile() for arguments [project ':javalib'] on org.grad
  le.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@46
  3ca82f.</p>
</blockquote></li>
</ul>

<p><a href="https://stackoverflow.com/a/23800903/51292">adding the java plugin</a> to the root build file did not help.</p>

<p>i don't think it's in the <a href="https://stackoverflow.com/a/23627293/51292">wrong place</a>.</p>

<p>both the root project and the added subproject have the gradle wrapper.</p>

<p>any pointers will be appreciated.</p>

<p>thanks</p>

<p>edit: for clarification, the root build file is:</p>

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

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
    }
    task hello &lt;&lt; { task -&gt; println "I'm $task.project.name" }
}

project(':app') {
    dependencies {
        //compile project(':javalib') // causes problems
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
</code></pre>

<p>and the app build file is:</p>

<pre><code>apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "acme.androidmain"
        minSdkVersion 22
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    //compile project(':javalib') // use :javalib:jar?
    //testCompile project(':javalib')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
}
</code></pre>

<p>edit: the whole purpose of this exercise is to get core java code into an android project. currently the core code is a standalone gradle/eclispe project. i have a batch in the android project that does a gradle -p standaloneprojectdir/ jar and copied the jar into libs/.</p>

<p>i just though there would be an easier way other than to publish the jar and get it from a repository since this all done on my pc.</p>

<p>it would be nice to have all the code live and just do a build :(</p>

<p>edit: as per <a href="https://stackoverflow.com/users/745574/rage">RaGe</a>'s suggestion, here is a <a href="https://github.com/rtayek/Virginandroidstudioproject" rel="noreferrer">virgin android studio project</a> and a <a href="https://github.com/rtayek/virginjavaproject.git" rel="noreferrer">virgin gradle/eclipse project</a>. no editing has been done to these files. you mission should you choose to accept it is to get the android app to easily access the java project classes (i.e. new Library(); in MainActivity.onCreate() will compile and run). i don't care where the java project lives. ideally, both sources would be <em>live</em> in both ide's.</p>

<p>atempting <a href="https://stackoverflow.com/a/17490233/51292">this</a> fails also. says: > Could not find :virginjavaproject, but directory does exist.</p>

<p>edit: what actually worked was RaGe's pull request to the <a href="https://github.com/rtayek/Virginandroidstudioproject" rel="noreferrer">virgin android project</a>.</p>