Android Multi Dex Build Failing

Builds were working fine for me until I introduced multi dex. Since then I haven’t had any luck. i have tried several different things I have seen on Stack Overflow and in this forum but nothing much as helped. This is my circle.yml file.

machine:
environment:
GRADLE_OPTS: ‘-Dorg.gradle.jvmargs="-Xmx4096m -Dorg.gradle.daemon=false -XX:+HeapDumpOnOutOfMemoryError"’

dependencies:
pre:
- chmod +x gradlew
- echo y | android update sdk --no-ui --all --filter android-27
- echo y | android update sdk --no-ui --all --filter build-tools-27.0.1

cache_directories:
- /usr/local/android-sdk-linux/build-tools/27.0.1
- /usr/local/android-sdk-linux/android-27
- /usr/local/android-sdk-linux/extras/android/m2repository

checkout:
post:
- cp -r licenses/. $ANDROID_HOME/licenses

test:
override:

    # create sdcard image file
    - mksdcard -l e 512M mysdcard.img
    # start the emulator
    - emulator -avd circleci-android24 -no-audio -no-window -sdcard mysdcard.img:
        background: true
        parallel: true
    - circle-android wait-for-boot
     # unlock the emulator screen
    - sleep 30
    - adb shell input keyevent 82

 
    
     # unlock the emulator screen
    - sleep 30
    - adb shell input keyevent 82

    # run tests against the emulator using spoon.
    - ./gradlew build -PpreDexEnable=false -Pcom.android.threadPoolSize=1 -Dorg.gradle.parallel=false -stacktrace



    # copy the test results to the test results directory.
    - cp -r app/build/spoon-output/* $CIRCLE_TEST_REPORTS