1

Can anyone tell my why dagger2 isn't working for me in Android Studio 3.1 preview?

  apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.orbitlab.mowerapp"
        minSdkVersion 23
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.google.firebase:firebase-messaging:11.4.2'
    implementation 'com.google.firebase:firebase-database:11.4.2'
    implementation 'com.google.firebase:firebase-auth:11.4.2'
    implementation "com.google.firebase:firebase-firestore:11.4.2"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.github.bumptech.glide:glide:4.3.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
    implementation 'com.android.support:customtabs:26.1.0'
    implementation 'com.google.android.gms:play-services-fitness:11.4.2'
    implementation 'com.google.android.gms:play-services-auth:11.4.2'
    implementation 'com.squareup.retrofit2:retrofit:2.2.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.2.0'

    annotationProcessor 'com.google.dagger:dagger-compiler:2.10'
    implementation 'com.google.dagger:dagger:2.10'

}

apply plugin: 'com.google.gms.google-services'

This is how my app's build.gradle file looks like. I haven't added anything in the project's build.gradle file.

Can anyone help?

Edit:

The gradle syncs now, but i get dex errors when trying to deploy to my device (havent used Dagger in this project yet). The error is:

Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'
Simon k
  • 403
  • 1
  • 5
  • 17

2 Answers2

0

Try to update dagger version and check it like this.

annotationProcessor 'com.google.dagger:dagger-compiler:2.10'
implementation 'com.google.dagger:dagger:2.10'
Mitesh Vanaliya
  • 2,491
  • 24
  • 39
0

You need to add following code to gradle file,

android {
    defaultConfig {
       multiDexEnabled true
    }
}

Then,

1.Clean your project

2.Build the code

Yogesh Nikam
  • 633
  • 5
  • 20