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
Related
I have two projects:
ProjectA makes use of ProjectB
ProjectA:
-- Settings.graddle:
include ':projectB'
-- build.gradle:
dependencies {
compile project(':projectB')
}
ProjectB:
-- build.gradle:
dependencies {
compile group: 'org.modelmapper.extensions', name: 'modelmapper-jackson', version: '1.1.1'
}
This imports into ProjectB the modelmapper-jackson lib. (Expected behaviour)
It also imports modelmapper-jackson lib into ProjectA.
It might be this is the behaviour I want, but:
I would like to understand how to define what it is imported and what it is not, since in the future I might have more projects, and do not want all of them to have all the libraries
Is there anything in gradle I missed?
You can use gradle dependencies to inspect your dependency graph.
There are multiple approaches to stop transitive dependencies.
Set dependency to compileOnly in project B*
compileOnly group: 'org.modelmapper.extensions', name: 'modelmapper-jackson', version: '1.1.1'
Exclude in project A
dependencies {
compile project(':projectB') {
exclude module 'modelmapper-jackson'
}
I'm adding the stepper indicator library - https://github.com/badoualy/stepper-indicator - to my project. To do so, I added jitpack to my project gradle file and the stepper-indicator library to my app gradle file. However, I'm getting the following build error:
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute meta-data#android.support.VERSION#value value=(25.4.0) from [com.android.support:preference-v14:25.4.0] AndroidManifest.xml:25:13-35
is also present at [com.android.support:appcompat-v7:26.0.0-beta2] AndroidManifest.xml:28:13-41 value=(26.0.0-beta2).
Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:23:9-25:38 to override.
The other dependencies in my app include:
compile 'com.android.support:preference-v7:25.4.0'
compile 'com.android.support:preference-v14:25.4.0'
compile 'eu.davidea:flexible-adapter:5.0.0-rc2'
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:recyclerview-v7:25.4.0'
compile 'com.android.support:cardview-v7:25.4.0'
compile 'com.android.support:support-v4:25.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services-gcm:11.0.2'
compile 'com.google.android.gms:play-services-auth:11.0.2'
compile 'com.google.android.gms:play-services-ads:11.0.2'
compile 'com.google.firebase:firebase-messaging:11.0.2'
compile 'com.google.firebase:firebase-auth:11.0.2'
compile 'com.squareup.okhttp3:okhttp:3.8.1'
Without upgrading all of the android support libraries to an alpha version, is there a solution to this problem?
In build.gradle you can exclude conflicting dependencies. For example:
compile ('com.github.badoualy:stepper-indicator:1.0.7'){
exclude group: 'com.android.support', module: 'appcompat-v7'
}
To inspect dependencies, you can use Gradle toolbar in Android Studio -> application module -> tasks -> android -> androidDependencies
Update:
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.
I am using 2 libraries in my application,which are having some common jar files.
So when i am trying to compile my application i am getting duplicate entry exception.I tried to exclude those jars in build.gradle for that perticular library project .
The code i wrote is
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile(project(':JIRAConnect')) {
exclude module: 'org.apache.httpcomponents:httpcore'
exclude module: 'org.apache.httpcomponents:httpclient'
exclude group: 'com.nostra13', module: 'universalimageloader'
}
compile (project(':..:GlobalLib:MyGlobalLib')){
exclude module: 'org.apache.httpcomponents:httpcore'
exclude module: 'org.apache.httpcomponents:httpclient'}
Can anyone give me the solution? Thanks in advance
In the 'open Module Settings' option and then click on the item MODULES, click the Dependencies tab.
Excluding the two jar files that you added.
(Not to be removed from the project. Merely to exclude. May include back at any time if necessary.)
I'm using Gradle in my Android application an I would like to use the JScience library dependency. I have added the library this way:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'org.jscience:jscience:4.3.1'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
But in the compile time I get the error:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Ljavax/realtime/MemoryArea;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
This is caused because of duplicating javax.realtime packages in project, one is a part of JDK, and the second one is in the Jscience library. I have tried to remove this package from Jscience library this way in Gradle:
sourceSets {
main {
java {
exclude 'javax/realtime/**'
}
}
}
configurations {
all*.exclude group: 'javax.realtime'
}
But that didn't help. So, that package is still exists in dependencies.
Is there any way how I can exclude a package from jar on compile time?
In case anybody needed, the problem was in Javolution dependency from JScience library. They both do hava a javax.runtime package. Excluding the Javolution has fixed the issue for me.
compile ('org.jscience:jscience:4.3.1') {
exclude group: 'org.javolution', module: 'javolution'
}