Home » Android » Android studio gradle duplicate files dagger compiler

Android studio gradle duplicate files dagger compiler

Posted by: admin May 14, 2020 Leave a comment


having strange problem after updating android studio to 0.4.0 and gradle plugin to 0.7.1 and gradle version to 1.9 with dagger compiler


android {
packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    dependencies {
    compile 'com.android.support:support-v4:+'
    compile 'com.android.support:support-v13:19.0.+'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.squareup.dagger:dagger:1.2.0'
    compile 'com.squareup.dagger:dagger-compiler:1.2.0'

on build getting this error

Execution failed for task ':MyApplication:packageDebug'.

Duplicate files copied in APK META-INF/services/javax.annotation.processing.Processor
File 1: C:\Users\Mantas.gradle\caches\modules-2\files-2.1\com.squareup.dagger\dagger-compiler\1.2.0\22633bb84433e03d345a83e7b0c08c66768be30\dagger-compiler-1.2.0.jar
File 2: C:\Users\Mantas.gradle\caches\modules-2\files-2.1\com.squareup.dagger\dagger-compiler\1.2.0\22633bb84433e03d345a83e7b0c08c66768be30\dagger-compiler-1.2.0.jar

if dagger compiler lines is commented everything works fine

how can i solve this problem?

fixed problem, check

How to&Answers:

If you know which files are being duplicated you can always compile them with exceptions like this:

dependencies {
   compile('com.squareup.dagger:dagger:1.2.0') {
   exclude module: 'moduleName' //by artifact name
   exclude group: 'groupName' //by group
   exclude group: 'com.unwanted', module: 'moduleName' //or by both
   compile 'com.squareup.dagger:dagger-compiler:1.2.0'

Just be sure that when you are doing this you enclose the dependancy in () to use the enclosure or it wont work.