square / dagger

A fast dependency injector for Android and Java.
https://square.github.io/dagger/
Apache License 2.0
7.31k stars 3.06k forks source link

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

Closed Kolyall closed 8 years ago

Kolyall commented 8 years ago

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()
    }
}
JakeWharton commented 8 years ago

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.

Kolyall commented 8 years ago

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?