Can not exclude files on Mac in packagingOptions of build.gradle

Hello, my issue looks stupid, but I did not find how to resolve it so far.
I have an error while running a small test application I am doing to learn Appium with Android Studio + Gradle on Mac(OS Sierra).

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/spring.tooling
  	File1: /Users/alexander/.gradle/caches/modules-2/files-2.1/org.springframework/spring-context/4.3.2.RELEASE/e52782b824e097c3b1586b497fc6be0e95020770/spring-context-4.3.2.RELEASE.jar
  	File2: /Users/alexander/.gradle/caches/modules-2/files-2.1/org.springframework/spring-aop/4.3.2.RELEASE/caef216e995f565dd4ab165ec5918ff44487615d/spring-aop-4.3.2.RELEASE.jar
  	File3: /Users/alexander/.gradle/caches/modules-2/files-2.1/org.springframework/spring-beans/4.3.2.RELEASE/9e87f48f65a33a017f2dd027911947a28be29f93/spring-beans-4.3.2.RELEASE.jar

I googled how to fix this issue and found that I should make exclude in packagingOptions section of build.gradle. And I did it:

apply plugin: ‘com.android.application’

android {

    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "com.example.alexander.appiumtest"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    packagingOptions {
        exclude '/Users/alexander/.gradle/caches/modules-2/files-2.1/org.springframework/spring-context/4.3.2.RELEASE/e52782b824e097c3b1586b497fc6be0e95020770/spring-context-4.3.2.RELEASE.jar'
        exclude '/Users/alexander/.gradle/caches/modules-2/files-2.1/org.springframework/spring-aop/4.3.2.RELEASE/caef216e995f565dd4ab165ec5918ff44487615d/spring-aop-4.3.2.RELEASE.jar'
        exclude '/Users/alexander/.gradle/caches/modules-2/files-2.1/org.springframework/spring-beans/4.3.2.RELEASE/9e87f48f65a33a017f2dd027911947a28be29f93/spring-beans-4.3.2.RELEASE.jar'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    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:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile group: 'io.appium', name: 'java-client', version: '4.1.2'
    compile group: 'junit', name: 'junit', version: '4.12'

    testCompile 'junit:junit:4.12'
}

But somehow I still have the same issue.
The interesting thing that in parallel I am doing the same on Windows and on Windows with the same error on running I fixed it by doing exclude in packagingOptions. But the same approach does not work on Mac.
I suspected that I used path to file in wrong way and tried different ways to write it in build.gradle: ‘\Users\alexander\…’, ‘//Users//alexander//…’, ‘\Users\alexander\…’, but it did not help.
Could anyone help me with this simple issue?

Has this problem been solved? I also encountered the same problem. If it is solved, can you share it?