title: IntelliJ, Android and Gradle
body: <p>I am trying to get my existing Android Project working with gradle and IntelliJ 12.
  Previously I had it working with maven but that didn't seem to be so flexible as gradle, and from what I think I got to know is that I need less subfolders.</p>
  
  <p>My Android project is divided into a clean java library (:core) and the actual Application (:android). These two projects are both in my main project folder.</p>
  
  <pre><code>~-+MainProject
    |--+core
    |  L--build.gradle
    |--+android
    |  L--build.gradle
    |--build.gradle
    L--settings.gradle 
  </code></pre>
  
  <p>I think the ideal solution to get gradle work with this is to treat the (:core) and (:android) project as nested projects, meaning I can simply be with my cmd in MainProject source folder to start the gradle tasks.</p>
  
  <p>However I came up with different problems:</p>
  
  <ol>
  <li>Gradle dependencies are only included in the core project
  <ul>
  <li>that means neither in the instrumentatetionTest nor in the main project files are any
  directories correctly set as source / test directories</li>
  <li>IntelliJ doesn't resolve any classes that I added as dependencies in gradle (AndroidSDK, junit, mockito, those from the :core project)
  <ul>
  <li>tried to use the plugin 'idea' but either I used it wrong or it didn't solve the problem</li>
  </ul></li>
  </ul></li>
  <li>I get duplicate dependency Error for building the APK
  <ul>
  <li>must have something to do with junit:4.11 and mockito-core:1.9.5 that I added</li>
  <li>what I tried: 
  <ul>
  <li>deleting the dependencys -> build fails cause some classes of course could'nt be resolved</li>
  <li>changing to junit:4.5+ as suggesed in some other thread -> no change at all</li>
  </ul></li>
  </ul></li>
  </ol>
  
  <p>Here are the *.gradle configuartions</p>
  
  <p>MainProject:
    -- settings.gradle</p>
  
  <pre><code>include ':core', ':android'
  </code></pre>
  
  <p>-- build.gradle</p>
  
  <pre><code>buildscript {
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:0.6.+'
      }
  }
  
  subprojects {
      repositories {
          mavenLocal()
          maven { url "http://repo.maven.apache.org/maven2" }
      }
  }
  </code></pre>
  
  <p>:core
    -- build.gradle</p>
  
  <pre><code>apply plugin: 'java'
  
  dependencies {
      testCompile 'junit:junit:4.11'
      testCompile 'org.mockito:mockito-core:1.9.5'
  }
  </code></pre>
  
  <p>:android</p>
  
  <pre><code>apply plugin: 'android'
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
       compile project(":core")
  
       compile 'com.google.android:android:4.1.1.4'
  
       instrumentTestCompile 'junit:junit:4.11'
       instrumentTestCompile 'org.mockito:mockito-core:1.9.5'
       instrumentTestCompile 'com.google.dexmaker:dexmaker:1.0'
       instrumentTestCompile 'com.google.dexmaker:dexmaker-mockito:1.0'
  
       instrumentTestCompile 'com.jayway.android.robotium:robotium-solo:3.6'
  } 
  
  /* ... androidSettings
  </code></pre>
  
  <p>I hope someone could help me with that</p>
  
  <p>MFG Dornathal</p>