I'm using Android Studio for the first time and I got the following error after importing the project (previously it was an eclipse project where I had issues too.)
Here is the information given:
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/home/crash-id/Development/SDK/adt-bundle-linux-x86_64-20140702/sdk/build-tools/21.1.2/dx --dex --no-optimize --output /home/crash-id/AndroidstudioProjects/LocalSin/app/build/intermediates/dex/debug --input-list=/home/crash-id/AndroidstudioProjects/LocalSin/app/build/intermediates/tmp/dex/debug/inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/home/crash-id/Development/SDK/adt-bundle-linux-x86_64-20140702/sdk/build-tools/21.1.2/dx --dex --no-optimize --output /home/crash-id/AndroidstudioProjects/LocalSin/app/build/intermediates/dex/debug --input-list=/home/crash-id/AndroidstudioProjects/LocalSin/app/build/intermediates/tmp/dex/debug/inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
The app build.gradle is this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.myapp.test"
minSdkVersion 11
targetSdkVersion 14
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:+'
compile files('libs/google-play-services.jar')
compile files('libs/httpcore-4.3.2.jar')
compile files('libs/httpmime-4.3.4.jar')
}
And the project built.gradle is this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Do you have any idea what the problem could be and how can it be solved? A good explanation for the problem would be useful too as I am new to Android Studio. Thanks in advance :)
compile 'com.google.android.gms:play-services:+'
compile files('libs/google-play-services.jar')
I think you should remove 1 of those lines.
cd android/ && ./gradlew clean && cd .. && react-native run-android
I had the Android Studio Error:Execution failed for task ':app:dexDebug' that i solve it by setting multiDexEnabled to true
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
Too many library were used in my project so i exceed the 65K methods dex limit imposed by Android for more information see : http://developer.android.com/tools/building/multidex.html
This happens because you are duplicating the library dependency inside of app build.gradle in android studio.
Android Studio automatically adds the dependencies for all the files in the libs folder by using
compile fileTree(dir: 'libs', include: ['*.jar'])
or in your specific case the dependency is added using
compile files('libs/google-play-services.jar')
^ Now when you try to add the dependency again by using
compile 'com.google.android.gms:play-services:+'
you get the error.
SOLUTION
Remove all duplicate dependencies added inside the "app build.gradle" and you should be good to go.In your case remove
compile 'com.google.android.gms:play-services:+'
avoid to include whole gms library:
compile 'com.google.android.gms:play-services:+'
Instead, just use required components in this way:
compile 'com.google.android.gms:play-services-ads:8.3.0'
compile 'com.google.android.gms:play-services-analytics:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
Ensure that the Package names are not duplicated across the projects being compiled
In #Drivers' answer, it is pointed out that in a given project, there should not be multiple dependencies that have the same namespace. In the case above, the Google Play Services library had been included twice, and thus caused a package name conflict.
The same can also happen across multiple modules (apps, libraries etc.) in the same project. So, ensure that for each AndroidManifest.xml file, the package name is unique across all modules:-
AndroidManifest.xml:
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="this.must.be.unique.across.modules">
I had the below code on gradle file and same error.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.google.android.gms:play-services-ads:8.3.0'
}
dependencies {
compile 'com.android.support:design:23.+'
}
dependencies {
compile 'com.android.support:design:23.+'
}
dependencies {
compile 'com.android.support:design:23.+'
}
Removed those last 3 dependencies and now its working!
delete all files in c:\users\<username>\.gradle\caches\transforms-2\files-2.1\
Enjoy the command flutter run
Related
I want to implement push notification.
I added to project level:
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.google.gms:google-services:3.0.0'
}
and to app level:(at the bottom of the file)
....
compile 'com.squareup.okhttp3:okhttp:3.3.0'
}
apply plugin: 'com.google.gms.google-services'
Then I added google-services.json file to project in app level
But, when I syncro gradle, it launch the error:
No matching client found for package name "...."
In gradle I have 2 different build variants , and look like:
Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="es.xxx.awsomeapp">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name=".realm.XXXXXX"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher_chv"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
And finally the gradle:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
maven { url "https://jitpack.io" }
maven { url 'http://dl.bintray.com/amulyakhare/maven' }
mavenCentral()
}
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
productFlavors {
vanilla {
applicationId "es.xxx.awsomeApp"
resValue 'string', 'app_name', "Awsome"
}
chv {
applicationId "es.xxx.awsomeApp.chv"
resValue 'string', 'app_name', "Awsome CHV"
signingConfig signingConfigs.chv_release
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests.returnDefaultValues = true
}
}
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'
})
//Auxiliar libraries
compile 'org.igniterealtime.smack:smack-android-extensions:4.2.0-beta2'
//Auxiliar libraries
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'org.igniterealtime.smack:smack-android-extensions:4.2.0-beta2'
compile 'org.igniterealtime.smack:smack-tcp:4.2.0-beta2'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta2'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.orhanobut:logger:1.15'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.github.Slyce-Inc:SlyceMessaging:1.1.2'
compile 'io.realm:android-adapters:1.4.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.rengwuxian.materialedittext:library:1.8.3'
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.okhttp3:okhttp:3.3.0'
compile 'com.google.firebase:firebase-messaging:9.8.0'
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.0'
testCompile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'org.igniterealtime.smack:smack-tcp:4.2.0-beta2'
testCompile 'com.android.support.constraint:constraint-layout:1.0.0-beta2'
testCompile 'com.android.support:design:24.2.1'
testCompile 'com.orhanobut:logger:1.15'
testCompile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
testCompile 'com.github.Slyce-Inc:SlyceMessaging:1.1.2'
}
apply plugin: 'com.google.gms.google-services'
And the firebase console.
How can I solve it?
Note, that json files are each one of their project.
Just go to the google-services.json
change the package-name to the name of your package
{
"client_info": {
"mobilesdk_app_id": "1:113908578702:android:a0a98decfd9f22466f4cdf",
"android_client_info": {
"package_name": "com.example.Appname"
}
}
}
sync your project, it'll be solved
I was facing the same error. I am using multiple flavors. Therefore, I put the google-services.json in app/src/{flv} directory.
It worked well for one flavor but did not work for others. The issue was that I have also placed google-services.json corresponding to flavor for which it was working in app directory also.
Google will search for sub-directories / flavor directories only if it did not find the google-services.json in the app directory.
So, make sure you don't put google-services.json in app directory in case you have separate google-services.json for multiple flavors.
Please see this article for mode details on Android product flavors.
I had the same problem, so using Android Studio 2.3.3 I used the menu
Tools> Firebase - on the right side of the window click Notifications and then Recieve notifications on your app,finally click Connect to Firebase, after this you will see a dialog saying This app is already connected to a project but just click Sync, then firebase will sync automatically all your app clients and it will fix this issue,by the way I know it's too late to respond but it might help someone.
If you have added google-service.json file
check build.gradle(: app) package_name and in google-service.json file package_name is the same
Also if you have added productFlavors make sure you have added that package in firebase for creating JSON file
Check your Gradle app level applicationId, it should be same as firebase package name, then it works like a charm
*Go to build.gradle and change the package name with same as AndroidManifest.xml and sync again *
[1][In this image show package name in AndroidManifest same as build.gradle]
[1]: https://i.stack.imgur.com/T4cqz.png
[Below image show package name in build.gradle same as AndroidManifest]
[2]: https://i.stack.imgur.com/ModHS.png
[package name in build.gradle][2]
Also check firebase and download recent .json file.
Update your applicationId inside defaultConfig of app level gradle file. With your package name.
Try to download the latest google-services.json file
it's a bit late, but maybe it could help someone like me with the same situation. I defined another app in the Firebase console at project settings with a different package name equal to my other flavor build. and then I downloaded the new google-services.json file and used it.it worked like a charm for me
I am trying to build my react-native project and using react-native fbsdk.
However, I get these errors:
/home/luiz/MYP/app/node_modules/react-native-fbsdk/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:3: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
/home/luiz/MYP/app/node_modules/react-native-fbsdk/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:4: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
/home/luiz/MYP/app/node_modules/react-native-fbsdk/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
/home/luiz/MYP/app/node_modules/react-native-fbsdk/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
:react-native-fbsdk:processReleaseResources FAILED
My current OS is Linux Elementary 0.4.1 Loki x64.
I am using react-native#0.37.0 and, because of this, react-native-fbsdk#0.4.0.
I've already tried:
cd android && ./gradlew clean
delete the project and re npm install it
and try in Android API's 23 and 24.
Apparently facebook has updated their sdk yesterday and the latest (4.23.0) sdk may have a bug or something.
You can resolve this by Changing your node_modules\react-native-fbsdk\android\build.gradle from:
compile('com.facebook.android:facebook-android-sdk:4.+')
To:
compile('com.facebook.android:facebook-android-sdk:4.22.1')
I'm no gradle guy so if someone knows of a better way of forcing the version from parent gradle.build, please comment and I'll update the answer.
** EDIT **
#Andreyco managed to solve this without changing node_modules. You can scroll down to his answer or click here.
Also, as notified by #JuanJoseTugores there's a pull request in react-native-fbsdk waiting to be approved, so you can check the bug's progress and be notified when it's resolved.
** Another Update **
Facebook closed the bug that was opened for them regarding this issue, saying they fixed the sdk. So now all the workarounds can be removed.
Apparently FB still not solved this. We just upgraded to RN 0.44 & FB 0.6.0
After digging into gradle, I came up with following solution.
Key is to exclude facebook-android-sdk required by react-native-fbsdk and pull in desired (working) version on facebook-android-sdk module - preferably without modifying anything in node_modules folder.
Fortunately, gradle offers this.
// android/app/build.gradle
dependencies {
compile(project(':react-native-fbsdk')){
exclude(group: 'com.facebook.android', module: 'facebook-android-sdk')
}
compile "com.facebook.android:facebook-android-sdk:4.22.1"
}
I was able to resolve this without modifying files under node_modules/.... I upgraded our react-native-fbsdk version to 0.6.0 and then add this to our application's build.gradle file to pin facebook-android-sdk at version 4.22.1:
project(':react-native-fbsdk') {
configurations.all {
resolutionStrategy {
force 'com.facebook.android:facebook-android-sdk:4.22.1'
}
}
}
configurations.all {
resolutionStrategy {
force 'com.facebook.android:facebook-android-sdk:4.22.1'
...
}
}
Edit: We are building with:
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
...
}
I just encountered this error. First, RN Facebook SDK v.0.6.0 only works for react-native >= 0.44.0, so you have to update your dependency in package.json to react-native: ^0.44.0. Then go to Android build.gradle file and make this changes: compileSdkVersion 25 and compile "com.android.support:appcompat-v7:25.0.0"
this fixed for me
in android/build.gradle
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
}
}
}
}
For those who are looking for make it work using RN 0.42 which by now is the one with react version stable you may need to use the Facebook SDK 4.18.0 "com.facebook.android:facebook-android-sdk:4.18.0" which is the one that was released by the time that react-native-fbsdk#0.5.0 was released, otherwise you may be ending up with the issue: https://developers.facebook.com/bugs/1712442065726889/
Besides, if you are getting hard times to force the facebook sdk to be what you need try this:
android/app/build.gradle
...
dependencies {
compile project(':react-native-fbsdk')
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile "com.facebook.android:facebook-android-sdk:[4.18.0)"
}
android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
project(':react-native-fbsdk') {
configurations.all {
resolutionStrategy {
force 'com.facebook.android:facebook-android-sdk:4.18.0'
}
}
}
...
allprojects {
repositories {
...
configurations.all {
resolutionStrategy {
force 'com.facebook.android:facebook-android-sdk:4.18.0'
}
}
}
}
As you can see here there is patches incoming,
https://github.com/facebook/react-native-fbsdk/pull/339
https://github.com/facebook/react-native-fbsdk/pull/338
in the meantime if you're using react-native-fbsdk v0.5 you could do
yarn add react-native-fbsdk#https://github.com/tugorez/react-native-fbsdk
I've applied the suggested changes and it's working :) but please be aware I'll no support this and wont keep it update so... as soon as you can you should go back to the official library.
My gradle version is 2.2.1.
I am trying to use the artifactory plugin in gradle (apply plugin: 'artifactory')
This is my code:
buildscript {
repositories {
maven {
url 'http://172.14.3.93/artifactory/plugins-release'
}
}
dependencies {
classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.9')
}
}
allprojects {
apply plugin: 'artifactory'
}
artifactory {
contextUrl = "${artifactory_contextUrl}" //The base Artifactory URL if not overridden by the publisher/resolver
publish {
repository {
repoKey = 'libs-release-local'
maven = true
}
}
resolve {
repository {
repoKey = 'libs-release'
maven = true
}
}
}
When i run gradle build, this is what i get:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Workspace\GradleConfiguration\build.gradle' line: 100
* What went wrong:
A problem occurred evaluating root project 'GradleConfiguration'.
> Failed to apply plugin [id 'artifactory']
> Could not find method add() for arguments [artifactoryPublish, class org.jfrog.gradle.plugin.artifactory.extractor.BuildInfoTask] on task set.
* Try:
Run with --info or --debug option to get more log output.
Also, when i delete all the code that is related to the artifactory and leave only apply plugin: 'artifactory', i get this error:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\OnRights_Workspace\GradleConfiguration\build.gradle' line: 86
* What went wrong:
A problem occurred evaluating root project 'GradleConfiguration'.
> Failed to apply plugin [id 'artifactory']
> Plugin with id 'artifactory' not found.
* Try:
Run with --info or --debug option to get more log output.
Your plugin version is too old. Try to use the latest (3.1.1).
The buildscript block tells Gradle where it should be looking for plugins. You've told it that it should only search at http://172.14.3.93/artifactory/plugins-release.
Are you 100% sure that the "artifactory" plugin is actually hosted there?
If you put jcenter in there, like the instructions say, does it work better?
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.0"
}
}
apply plugin: "com.jfrog.artifactory"
I'm new into Android Studio and Facebook SDK. I followed the guide reported here: https://developers.facebook.com/docs/android/getting-started till step 6.
but I'm unable to use none of Facebook's functions. I get compilation errors for every Facebook functions I try. Also, I get an "unable to resolve symbol" for import com.facebook.FacebookSdk.
Is there something I'm doing wrong or I should configure before importing the library? I just created a new Empty Project
here the build.gradle of the Project:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
and here the module for the app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "com.ozetastudios.climbbuddy"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.facebook.android:facebook-android-sdk:3.23.0'
}
I pulled most of my hair out to figure this out, and it may not be universally applicable. But it solved this issue for me.
In your highest level build.gradle file, add the Maven Central repositories:
repositories {
jcenter() // Default repository
mavenCentral() // You add this line
}
In the app-level build.gradle file, add this block:
dependencies {
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
}
The SDK version has to be valid. You can check for the latest in the Maven Repo by looking here.
Now, here's the part were the Facebook Tutorial is opaque. "You can now import com.facebook.FacebookSDK" meant nothing to me, as a newbie to Android Studio (My app is in Cordova, and I usually only use Android Studio to compile) I kept trying to import that address as a module from the File > New menu. Nope. Path does not exist. Of course it doesn't. It's not a path. WTF. But then I noticed other "import" objects as lines of code in the main activity file. Light bulb. So THAT's what the Facebook Tutorial meant. It felt like unlocking Tutankhamun's puzzle.
I inserted the following line into my application's main activity file:
import com.facebook.appevents.*;
And THAT, my fellow frustrates, worked for me.
I'm trying to exclude a dependency, mainly "slf4j-simple" from my gradle build. It works well, but is not reflected when I run "gradle eclipse".
I have the following code in my gradle build file:
apply plugin:'war'
apply plugin:'eclipse'
apply plugin:'jetty'
...
dependencies {
compile 'mysql:mysql-connector-java:5.1.16'
compile 'net.sourceforge.stripes:stripes:1.5'
compile 'javax.servlet:jstl:1.2'
... (Rest of the dependencies)
}
configurations {
all*.exclude group:'org.slf4j',module:'slf4j-simple'
}
Now, when I run 'gradle build', the slf4j-simple is excluded from the war file created which is fine.
When I run 'gradle eclipse', the slf4j-simple is not excluded from the eclipse classpath.
A solution to the problem is mentioned in the gradle cookbook but I don't understand how to apply it:
http://docs.codehaus.org/display/GRADLE/Cookbook#Cookbook-ExcludingdependenciesfromEclipseProjects
Try adding this to your build.gradle:
eclipseClasspath{
plusConfigurations.each{
it.allDependencies.each{ it.exclude group: 'org.slf4j', module: 'slf4j-simple' }
}
}
With gradle 1.0-milestone-3 I had to do a modification from rodion's answer to make it work:
eclipseClasspath{
doFirst{
plusConfigurations.each{
it.allDependencies.each{ it.exclude group: 'org.slf4j', module: 'slf4j-simple' }
}
}
}
Using eclipseClasspath didn't work for me, but this does the trick:
configurations {
compile {
exclude group: 'commons-logging'
exclude module: 'jcl-over-slf4j'
}
}
That excludes commons-logging from being included transitively (from the project's dependency on Spring) and also jcl-over-slf4j from being included in the Eclipse project's build path (I have a Gradle runtime dependency on jcl-over-slf4j but don't want it included on the build (compile) path.
This works in Gradle 4.10
eclipse {
classpath {
file {
whenMerged { cp ->
cp.entries.removeAll { (it instanceof Library) && it.moduleVersion?.group == 'org.slf4j' && it.moduleVersion?.name == 'slf4j-simple' }
}
}
}
}