doo / scanbot-sdk-example-android

Integrate the Android Document Scanner Library from Scanbot SDK into your project
https://scanbot.io/developer/android-document-scanner-sdk/
101 stars 46 forks source link

Build fails with duplicate entry: javax/inject/Inject.class #21

Closed aphexcx closed 7 years ago

aphexcx commented 7 years ago

Hi, I can't get our project to build with the Scanbot "io.scanbot:sdk-package-1:1.19.0" dependency. build.gradle:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        jcenter()
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.22.0'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.1'
        classpath 'me.tatarka:gradle-retrolambda:3.2.5'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'io.fabric'
apply plugin: 'com.getkeepsafe.dexcount'

repositories {
    jcenter()
    maven {
        url 'https://maven.fabric.io/public'
    }
    maven {
        url 'http://mobile-sdk.jumio.com'
    }
}

android {
    compileSdkVersion 24
    buildToolsVersion '25.0.0'

    defaultConfig {
        ext.buildNumber = System.getenv("BUILD_NUMBER") ?: 0
        ext.betaDistributionGroupAliases = "ext"
        ext.betaDistributionNotifications = false
        applicationId PMApplicationId
        minSdkVersion minSdk
        targetSdkVersion 22
        versionCode buildNumber as int
        versionName "1.20.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
    }

    dexOptions {
        jumboMode = true
    }

    buildTypes {
        debug {
            minifyEnabled false
        }

        release {
            minifyEnabled true
        }
    }

    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    testOptions {
        unitTests.all {
            jvmArgs '-XX:MaxPermSize=256m'
            unitTests.returnDefaultValues = true
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':core-android')
    compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
        transitive = true;
    }

    //Google GMS
    compile 'com.google.android.gms:play-services-location:10.0.1'
    compile 'com.google.android.gms:play-services-maps:10.0.1'
    compile 'com.google.android.gms:play-services-gcm:10.0.1'

    //Google support
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:support-v13:24.2.1'
    compile 'com.android.support:cardview-v7:24.2.1'
    compile 'com.android.support:recyclerview-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:percent:24.2.1'
    compile 'com.android.support:support-vector-drawable:24.2.1'
    compile 'com.android.support:support-annotations:25.0.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.code.findbugs:jsr305:3.0.1'

    //General
    compile 'uk.co.chrisjenx:calligraphy:2.2.0'
    compile 'com.jakewharton.threetenabp:threetenabp:1.0.4'

    //Bleeding edge
    compile 'com.squareup.okhttp3:okhttp:3.2.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    compile 'com.squareup.retrofit2:retrofit:2.0.0'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0'
    compile 'com.squareup.retrofit2:converter-gson:2.0.0'
    compile 'com.squareup.retrofit2:converter-scalars:2.0.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.facebook.fresco:fresco:0.14.1'
    compile "com.facebook.fresco:imagepipeline-okhttp3:0.14.1"

    compile 'com.jakewharton:butterknife:7.0.1'

    compile 'com.orhanobut:logger:1.15'

    //Rx
    compile 'io.reactivex:rxandroid:1.0.1'
    compile 'com.tbruyelle.rxpermissions:rxpermissions:0.7.0@aar'
    compile 'com.trello:rxlifecycle:1.0'
    compile 'com.trello:rxlifecycle-android:1.0'
    compile 'com.trello:rxlifecycle-components:1.0'
    //future: for kotlin
//    compile 'com.trello:rxlifecycle-kotlin:1.0'
    compile 'com.jakewharton.rxbinding:rxbinding:0.4.0'

    //Rx lint checks
    compile 'io.vokal.lint:rxlifecycle:1.0.2'
    compile 'nl.littlerobots.rxlint:rxlint:1.0'

    //Dagger
    compile 'com.google.dagger:dagger:2.8'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.8'

    //Animation
    compile 'com.eftimoff:android-pathview:1.0.8@aar'

    //UI
    compile 'com.wdullaer:swipeactionadapter:2.0.0'

    //Jumio:
    compile 'com.jumio.android:core:2.4.0@aar'
    compile 'com.jumio.android:nv:2.4.0@aar'
    compile 'com.jumio.android:nv-mrz:2.4.0@aar'
    compile 'com.jumio.android:nv-barcode:2.4.0@aar'
    compile 'com.jumio.android:nv-barcode-vision:2.4.0@aar'
    compile 'com.jumio.android:nv-nfc:2.4.0@aar' 
    compile 'com.jumio.android:nv-ocr:2.4.0@aar'
    //Javadoc
    compile 'com.jumio.android:javadoc:2.4.0'

    //Scanbot receipt scanning
    compile "io.scanbot:sdk-package-1:1.19.0"

    //Analytics
    compile 'com.mparticle:android-core:4.9.1'

    //Android Tests
    androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
    androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
    androidTestCompile 'org.mockito:mockito-core:1.9.5'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
    androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
    androidTestCompile 'com.android.support:support-annotations:25.0.0'
    androidTestCompile 'com.google.code.findbugs:jsr305:3.0.1'

    //Unit Tests
    testCompile 'junit:junit:4.12'
    testCompile "org.mockito:mockito-core:1.9.5"
}

Full debug output of ./gradlew:

01:02:25.827 [DEBUG] [com.android.build.gradle.internal.transforms.JarMerger] addJar(/Users/veerenmandalia/.gradle/caches/modules-2/files-2.1/javax.inject/javax.inject/1/6975da39a7040257bd51d21a231b76c915872d38/javax.inject-1.jar)
01:02:25.827 [DEBUG] [com.android.build.gradle.internal.transforms.JarMerger] addJar(/Users/veerenmandalia/.gradle/caches/modules-2/files-2.1/javax.inject/javax.inject/1/6975da39a7040257bd51d21a231b76c915872d38/javax.inject-1.jar): entry javax/inject/Inject.class
01:02:25.840 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Removed task artifact state for {} from context.
01:02:25.840 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':app:transformClassesWithJarMergingForPreAlphaDebug'
01:02:25.840 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] :app:transformClassesWithJarMergingForPreAlphaDebug FAILED
01:02:25.841 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :app:transformClassesWithJarMergingForPreAlphaDebug (Thread[Daemon worker,5,main]) completed. Took 0.869 secs.
01:02:25.841 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationWorkerRegistry] Worker root.132 completed (0 in use)
01:02:25.841 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[Daemon worker,5,main]] finished, busy: 17.047 secs, idle: 0.047 secs
01:02:25.849 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
01:02:25.850 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
01:02:25.850 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
01:02:25.850 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
01:02:25.850 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':app:transformClassesWithJarMergingForPreAlphaDebug'.
01:02:25.850 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: javax/inject/Inject.class
01:02:25.850 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
01:02:25.850 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
01:02:25.850 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.
01:02:25.851 [LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger]
01:02:25.851 [LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED
aphexcx commented 7 years ago

So far after hours of debugging (still no luck), this looks like it's because we're using Dagger in our project, and Scanbot uses RoboGuice. Both of these libraries make use of the javax.inject annotation, and so they clash. I still have not figured out how to make Scanbot work in a project that uses Dagger.

aphexcx commented 7 years ago

I've tried excluding the javax.inject module with this directive, but it didn't work:

compile ('io.scanbot:sdk-package-1:1.19.0') {
        exclude module: 'javax.inject'
    }
dmitry-zaitsev commented 7 years ago

You can try adding direct dependency for javax.inject:

compile 'javax.inject:javax.inject:1'

That is supposed to make both RoboGuice and Dagger depend on the same version of javax.inject. We will look into the problem in more details next year - currently the whole team is on vacation.

aphexcx commented 7 years ago

Thanks Dmitry. I tried that and it didn't work. Want to try reproducing on your end? Simply try adding Dagger 2.8 to a project that also uses Scanbot 1.19.0.

aphexcx commented 7 years ago

Hi, any update on this?

Kubiria commented 7 years ago

We are investigating the issue

Kubiria commented 7 years ago

Seems like excluding javax.inject from dagger dependencies solves the problem.

compile ('com.google.dagger:dagger:2.8') {
    exclude (group:'javax.inject', module:'javax.inject')
}