Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio gradle duplicate files dagger compiler

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

build.gradle

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? thanks

EDITED fixed problem, check https://plus.google.com/+HugoVisser/posts/7Wr3FcdNVxR

like image 364
Palaima Avatar asked Dec 20 '13 19:12

Palaima


1 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.

like image 64
astryk Avatar answered Oct 15 '22 02:10

astryk