2

I am able to build the Project successfully in Android Studio but when I am trying to run the application getting error like this "duplicate entry: android/support/v4/print/PrintHelper$1.class.",I have searched lot of sites and tried lot of suggestions but failed.Please help me..below is my code.I was struggled 2 days for this.

 apply plugin: 'com.android.application'
dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':appcompat_v7')
    compile project(':google-play-services_lib')
    compile project(':Cognalys')
    //noinspection GradleDynamicVersion
    compile 'com.android.support:recyclerview-v7:22.2.+'
}
android {
    compileSdkVersion 22
    buildToolsVersion "23.0.0 rc3"
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
    defaultConfig {
        // Enabling multidex support.
        multiDexEnabled true
    }
    buildTypes {
       release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

2 Answers2

0

I meet the same error, and I solve it, but I just give u that my case;

my bulid.gradle:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile ('com.android.support:appcompat-v7:22.0.0') 
    compile files('libs/android-async-http-1.4.8.jar')
    compile files('libs/android-support-v4.jar')
    compile files('libs/universal-image-loader-1.9.4-with-sources.jar')
}

the error for is the com.android.support:appcompat-v7:22.0.0 include the support-v4.jar, so I remove it;

solve build.gradle:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile ('com.android.support:appcompat-v7:22.0.0') {
        exclude module: 'support-v4'
    }
    compile files('libs/android-async-http-1.4.8.jar')
    compile files('libs/android-support-v4.jar')
    compile files('libs/universal-image-loader-1.9.4-with-sources.jar')
}

so maybe u should check ur dependencies, maybe ur compile files have two files include support-v4

King of Masses
  • 18,405
  • 4
  • 60
  • 77
0

This question is that "duplicate entry " ,when ".java" become ".class" different jar maybe have the same class, your project maybe depend on many different libs which may have many jars ,so the key to solve this error is that avoid duplicate jar,as much as possible use online depend on not local jars,all this things can config in your gradle

for example: compile files('libs/com.nostra13.universalimageloader:universal-image-loader:1.9.5') need to change to compile'com.nostra13.universalimageloader:universal-image-loader:1.9.5'.

If you have to use a local jar, please make sure that in your prject and the libs that project depends on they share one jar.