square / dagger

A fast dependency injector for Android and Java.

Home Page:https://square.github.io/dagger/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to make “provided” scope working on Android Studio?

Kolyall opened this issue · comments

How to make "provided" scope working for dagger on Android Studio?
After run of my project I have this issue:
Module adapter for class com.example.Module could not be loaded. Please ensure that code generation was run for this module.

 buildscript {
        repositories {
            mavenCentral()
        }
    }
apply plugin: 'com.android.application'

configurations {
    provided
}

android {
    buildTypes {
        release {
            minifyEnabled true
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-android.txt'
            debuggable false
        }

    }

    sourceSets {
        main {
            java.srcDirs = ['/src/main/java']
            res.srcDirs = ['/src/main/res']
            assets.srcDirs = ['/src/main/assets']
              }
    }


}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.squareup.dagger:dagger:1.2.2'
    provided 'com.squareup.dagger:dagger-compiler:1.2.2'
}

Top gradle:

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

allprojects {
    repositories {
        jcenter()
    }
}

Since this is a usage question and not a feature request or bug it's best suited for StackOverflow, and I see you've already asked it there: http://stackoverflow.com/q/35646368/132047 so I'll defer to it.

Please explain, because in your description there is no any tutorials "how to integrate it with Android Studio"
Only "You will need to include the Dagger JAR in your application's runtime. In order to activate code generation you will need to include the compiler JAR in your build at compile time."
But how to make it?