ProGuard - Dagger duplicate zip entry


#1

Using Dagger 2.+ conflicts with Affdex dependency of Dagger 1.+, and the following error occurs when running gradle build

Warning: Exception while processing task java.io.IOException: Can’t write […] (Can’t read […/com.squareup.dagger/dagger/1.2.2/…/dagger-1.2.2.jar(;;;;;;**.class)] (Duplicate zip entry [dagger-1.2.2.jar:dagger/Lazy.class]))

Use this build.gradle to reproduce:

android {
  compileSdkVersion 26
  buildToolsVersion "26.0.0"
  defaultConfig {
    applicationId "com.example.myapplication4"
    minSdkVersion 21
    targetSdkVersion 26
    multiDexEnabled true
  }
  buildTypes {
    release {
      minifyEnabled true
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
}
dependencies {
  compile fileTree(include: ["*.jar"], dir: "libs")
  compile "com.android.support:appcompat-v7:26.+"
  compile "com.google.dagger:dagger:2.+"
  compile "com.affectiva.android:affdexsdk:3.+"
}

I tried adding an exclude clause

  compile ("com.affectiva.android:affdexsdk:3.+") {
    exclude group: "com.squareup.dagger", module: "dagger"
  }

but that led to an application failure.
Strangely enough the following does not lead to the error:

dependencies {
  compile fileTree(include: ["*.jar"], dir: "libs")
  compile "com.android.support:appcompat-v7:26.+"
  compile "com.google.dagger:dagger:2.+"
  compile "com.squareup.dagger:dagger:1.2.2"
}

Any idea how can I investigate further?


#2

Tried to run the following task:

task findDuplicates() {
  doLast {
    Map grouped = [:]
    configurations.compile.each { jarFile ->
      fileTree(jarFile).visit { FileVisitDetails fvd ->
          def path = fvd.relativePath.path
          def matches = grouped[path] ?: []
          matches << jarFile
          grouped[path] = matches
      }
      grouped.each { path, matches -> if (matches.size() > 1) println "found $path in $matches"
      }
    }
  }
}

But got a permission error:

  • What went wrong:
    A problem occurred configuring project ‘:app’.

Could not resolve all dependencies for configuration ‘:app:_debugApkCopy’.
Could not resolve com.affectiva.android:affdexsdk:3.+.
Required by:
project :app
Could not resolve com.affectiva.android:affdexsdk:3.+.
Failed to list versions for com.affectiva.android:affdexsdk.
Unable to load Maven meta-data from h-ttp://maven.affectiva.com/com/affectiva/android/affdexsdk/maven-metadata.xml.
Could not GET ‘h-ttp://maven.affectiva.com/com/affectiva/android/affdexsdk/maven-metadata.xml’.
maven.affectiva.com

Perhaps you could run it on your end?


#3

hi, catching up on some old posts, sorry for the delayed reply. This looks like a network issue when attempting to access our maven repo. As it happens, we had a problem over this past weekend with that repo (which has been resolved), but it looks like your occurrence happened a while ago. I’m assuming you resolved it already?


#4

Closing due to lack of activity.


#5