我的gradle执行失败,并显示下面列出的错误消息。我已经在SO上搜索了一些其他答案,建议这样做:
dexOptions {
preDexLibraries = false
}
有人说它可能是一个内存错误,有人说它可能已经包含了我尝试编译的依赖项之一。我已将下面的错误消息与build.gradle文件一起包含在内,您可以在其中查看我正在使用的依赖项。非常感谢任何帮助!
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')
}
失败:构建因异常而失败。
执行失败
com.android.ide.common.internal.LoggedErrorException:无法运行命令: / Applications / Android Studio.app/sdk/build-tools/android-4.4W/dx --dex --num-threads = 4 --output ... 错误代码: 137
答案 0 :(得分:0)
运行dx需要生成新VM。创建失败,检查是否有足够的内存和/或设置defaultXmx = -Xmx512m(或更低)。另请查看Android gradle build script returns error 137 in preDexDebug
中的答案