Gradle compile error with same module - java

i am trying to import 2 Libraries with Gradle.
When i am importing one of them its working but when i compile both i get the exception below.
I am working with Android Studio.
Getting the exception below:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/bouncycastle/crypto/CipherParameters.class
and my dependencies:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile ('org.bouncycastle:bcprov-jdk15on:1.50') {
exclude module: 'bcpkix-jdk15on' // Excluded to prevent cyclic dependencies
}
compile ('org.bouncycastle:bcpkix-jdk15on:1.50') {
exclude module: 'bcprov-jdk15on' // Excluded to prevent cyclic dependencies
}
}
Thanks
Marvin

Android is already using a cut down version of bouncy castle. It worked with com.madgag.spongycastle.

Related

I donĀ“t understand: Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'

I don't understand this error:
Error:
Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/print/PrintHelper$PrintHelperStubImpl.class
Code:
dependencies {
compile ('com.google.android.gms:play-services:+'){exclude module: 'support-v4'}
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
compile ('com.android.support:multidex:1.0.1'){exclude module: 'support-v4'}
}
Thanks in advance
Try removing the line compile files('libs/support-v4-19.0.1.jar') (and probably {exclude module: 'support-v4'}). It is probably the android/support/v4 library, which is already inside the default classpath when compiling android projects.

How to solve A library uses the same package as this project?

How do I fix this?
Error:Execution failed for task ':androidmapsutils:processReleaseResources'.
> Error: A library uses the same package as this project: com.google.maps.android
If you use enforceUniquePackageName=false you'll eventually stumble upon this bug -
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'. java.util.zip.ZipException: duplicate entry: ... BuildConfig.class
and in order to fix that you'll have to check if some of your dependencies have multidex as a dependency in it and exclude it, for example the Facebook SDK -
compile('com.facebook.android:facebook-android-sdk:+') {
exclude group: 'com.android.support', module: 'multidex'
}
You can refer to this Stack Overflow and this Issue Tracker
compile project(path: ':backend', configuration: 'android-endpoints')
compile project(':library')
Check included package name
com.google.maps.android.

Gradle DSL method not found: exclude()

i am using a lot of library in my project. And some libraries using same jar file therefore i writed this on build.gradle :
dependencies {
compile fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.twotoasters.jazzylistview:library:1.2.1'
compile 'com.google.firebase:firebase-core:10.2.4'
compile 'com.google.firebase:firebase-database:10.2.4'
compile 'com.orhanobut:dialogplus:1.11#aar'
compile 'com.github.recruit-lifestyle:FloatingView:2.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.nineoldandroids:library:2.4.0'
compile ('com.specyci:residemenu:1.6+'){
exclude group: 'com.nineoldandroids', module: 'library' }
compile files('libs/poppyview.jar'){
exclude group: 'com.nineoldandroids', module: 'library' }
}
And i am getting error :
Error:(54, 0) Gradle DSL method not found: 'exclude()'
Possible causes:The project 'DopingEng' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 2.3.1 and sync projectThe project 'DopingEng' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
Apply Gradle plugin
Gradle already update , how can i solve this problem ?
Here's the problem
compile files('libs/poppyview.jar'){
exclude ...
}
A file based dependency does not work in the same way as a dependency coming from a repository. There is no meta data associated with it (eg no dependency information) so there's also nothing to exclude (since there's no transitive dependencies).
Do you have the pom/ivy meta-data for libs/poppyview.jar? If so then you shouldn't declare it like this (I suggest a local maven repository folder). If you don't then there's nothing to exclude

java.util.zip.ZipException: duplicate entry error

here's my build.gradle dependencies part :
`
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.0'
compile files('libs/google-play-services.jar')
compile files('libs/android-async-http-1.4.9.jar')
compile 'cz.msebera.android:httpclient:4.3.6'
compile 'com.google.android.gms:play-services-location:7.+'
and my error is :
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/UserRecoverableAuthException.class
what's the cause of the error ??
You are adding google-play-services twice in your gradle file.
compile files('libs/google-play-services.jar')
compile 'com.google.android.gms:play-services-location:7.+'
Remove the following line from your build.gradle file.
compile files('libs/google-play-services.jar')
you need use multidex in project link

java.lang.NoClassDefFoundError: org.apache.commons.lang3.StringUtils

I am trying to use OpenCSV library in my project and it is throwing up this error- I have already tried to delete the library and reinstall it and the error persists.
This is from the build.gradle
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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('libs/opencsv.jar')}
I am curious as to why you have your own opencsv.jar? Is it because you did customizations or do you have firewall issues where you are only allowed to go to an internal maven repository during compilation?
If so Prathmesh hit the nail on the head in that you will have to bring in all the transitive dependencies yourself. The dependencies of the latest version can be found at the opencsv sourceforge page. Currently opencsv is dependent on commons-lang3 and commons-beanutils.
Otherwise just change your "compile files" line to compile 'com.opencsv:opencsv:3.9' and let gradle get all your transitive dependencies for you.
Add the dependency for org.apache.commons.lang3.StringUtils in build.gradle.

Categories