title: Adding Dagger-2 to Android Studio
body: <p>I asked this question previously <a href="https://stackoverflow.com/questions/35981039/instrumentation-doesnt-inject-touch-in-rooted-device">https://stackoverflow.com/questions/35981039/instrumentation-doesnt-inject-touch-in-rooted-device</a> which states that <code>instrumentation</code> doesn't work on <code>Lollipop</code> and later versions. After some deep search I found that we should add <code>Dagger-2</code> to be compiled with the project. I used the steps related to gradle available here: <a href="https://github.com/codepath/android_guides/wiki/Dependency-Injection-with-Dagger-2" rel="nofollow noreferrer">https://github.com/codepath/android_guides/wiki/Dependency-Injection-with-Dagger-2</a></p>
  
  <p>This is my build.gradle: </p>
  
  <pre><code>buildscript {
      repositories {
          jcenter()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:1.1.0'
          classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
  
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  
  allprojects {
      repositories {
          jcenter()
      }
  }
  </code></pre>
  
  <p>This is app/build.gradle: </p>
  
  <pre><code>apply plugin: 'com.android.application'
  apply plugin: 'com.neenbedankt.android-apt'
  
  android {
      compileSdkVersion 19
      buildToolsVersion "19.1.0"
  
      defaultConfig {
          applicationId "com.project.android.vecsat"
          minSdkVersion 10
          targetSdkVersion 19
          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 'com.android.support:appcompat-v7:19.0.0'
      compile 'com.android.support:support-v4:19.0.0'
      apt 'com.google.dagger:dagger-compiler:2.0.2'
      compile 'com.google.dagger:dagger:2.0.2'
      provided 'org.glassfish:javax.annotation:10.0-b28'
      compile project(':libraries:opencv')
  
  }
  </code></pre>
  
  <p>After synchronizing the project, nothing was fixed. Still instrumentation doesn't work. I found another guide here: <a href="https://github.com/kkovach/dagger/blob/update-install-gradle/README.md" rel="nofollow noreferrer">https://github.com/kkovach/dagger/blob/update-install-gradle/README.md</a></p>
  
  <p>But, I don't know where to place dagger jar file, and I can't figure out where is <code>java gradle</code>. </p>
  
  <p>Can somebody please help me? What are the correct steps to add <code>Dagger-2</code> to the project? </p>