0

This is my app gradle file.The exact error I am getting is the following

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.>com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/github/barteksc/pdfviewer/listener/OnPageChangeListener;

build.gradle :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.daniel.haughton93.dunnesstoresoffers"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {}
}

dependencies {

    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support',
        module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    testCompile 'junit:junit:4.12'
    compile files('src/main/java/com/daniel/haughton93/dunnesstoresoffers/jsoup-1.10.1.jar')
    compile 'com.google.android.gms:play-services-appindexing:8.4.0'
    compile 'com.github.barteksc:android-pdf-viewer:2.3.0'
}
Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159
Daniel
  • 199
  • 2
  • 4
  • 18

2 Answers2

0

This problem is due to android-pdf-viewer dependency so try below steps might be you will get solution.

  1. Remove the all build folder from project structure.
  2. MyProject folder -> build -> intermediate -> dex-cache -> cache.xml, and deleted all support-v4.jar and android-pdf-viewer.jar items.
  3. clean the project and try again
Khushvinder
  • 298
  • 1
  • 9
0

I would suggest that you really take out all the id's and references that you do not need and make a Clean Project and then Rebuild.

If the above does not work then modify the build.gradle(Modude:app) like this:

android {
    defaultConfig {
        ...
        minSdkVersion 21 
        targetSdkVersion 25
        multiDexEnabled true <-- the line that matters
    }
    ...
}

Hope it helps!!!

Kostas Drak
  • 3,222
  • 6
  • 28
  • 60