0

My gradle execution fails with the error message listed below. I have searched a number of other answers on SO that suggest doing this:

dexOptions {
        preDexLibraries = false
    }   

Some say it may be a memory error, some say it may be that a dependency may already include one of the dependencies I'm trying to compile. I've included the error message below along with my build.gradle file where you'll e able to see what dependencies I'm using. Any help is much appreciated!

buildscript {
   repositories {
     jcenter()
    maven { url 'https://maven.fabric.io/public' }
} 
dependencies {
    classpath 'com.android.tools.build:gradle:0.13.3'
    // The Fabric Gradle plugin uses an open ended version to react
    // quickly to Android tooling updates
    classpath 'io.fabric.tools:gradle:1.+'
 }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    jcenter()
   maven { url 'https://maven.fabric.io/public' }
}

android {
compileSdkVersion 21
buildToolsVersion '20.0.0'

defaultConfig {
    applicationId "com.dreamengine.shout"
    minSdkVersion 13
    targetSdkVersion 21
}

buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
dexOptions {
    preDexLibraries = false
}

}

dependencies {
//compile 'com.android.support:support-v4:+'
compile files('libs/Parse-1.7.1.jar')

compile 'com.squareup.picasso:picasso:2.3.4'
compile 'com.firebase:firebase-client-android:2.0.3'
compile 'com.squareup.okio:okio:1.0.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.1.0'
compile 'com.squareup.okhttp:okhttp:2.1.0'
compile 'com.squareup.retrofit:retrofit:1.8.0'
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.google.android.gms:play-services:6.5.+'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.github.asne.facebook:facebook:3.17.2'
compile 'com.braintreepayments.api:braintree:1.+'
compile "com.mixpanel.android:mixpanel-android:4.4.1@aar"

// Crashlytics Kit
compile('com.crashlytics.sdk.android:crashlytics:2.1.0@aar') {
    transitive = true
}

// Twitter Kit
compile('com.twitter.sdk.android:twitter:1.1.0@aar') {
    transitive = true
}

// MoPub Kit
compile('com.mopub.sdk.android:mopub:3.2.2@aar') {
    transitive = true
}

//Foursquare
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':Libraries:easyFoursquare4Android')

}

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: /Applications/Android Studio.app/sdk/build-tools/android-4.4W/dx --dex --num-threads=4 --output ... Error Code: 137

cph2117
  • 2,651
  • 1
  • 28
  • 41

1 Answers1

0

Running of dx requires spawning a new VM. Creating fails, check if you have enough memory and/or set defaultXmx=-Xmx512m (or lower). Please also check out the answers here Android gradle build script returns error 137 in preDexDebug

Community
  • 1
  • 1
wgitscht
  • 2,676
  • 2
  • 21
  • 25
  • I went to File -> Settings -> Compiler and in VMOptions, I entered -Xmx512m -XX:MaxPermSize=512m, but it still didn't work – cph2117 Dec 14 '14 at 06:23