Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.internal.LoggedErrorException: Failed to run command: C:\Users\xxx\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --multi-dex --main-dex-list C:\___\android\GooglePlus_1\app\build\intermediates\multi-dex\debug\maindexlist.txt --output C:\___\android\GooglePlus_1\app\build\intermediates\dex\debug --input-list=C:\___\android\GooglePlus_1\app\build\intermediates\tmp\dex\debug\inputList.txt Error Code: 3 UNEXPECTED TOP-LEVEL ERROR: java.lang.OutOfMemoryError: Java heap space at com.android.dx.dex.code.RopTranslator.outputBlock(RopTranslator.java:253) at com.android.dx.dex.code.RopTranslator.outputInstructions(RopTranslator.java:233) at com.android.dx.dex.code.RopTranslator.translateAndGetResult(RopTranslator.java:212) at com.android.dx.dex.code.RopTranslator.translate(RopTranslator.java:105) at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:317) at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137) at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93) at com.android.dx.command.dexer.Main.processClass(Main.java:729) at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673) at com.android.dx.command.dexer.Main.access$300(Main.java:83) at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602) at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166) at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) at com.android.dx.command.dexer.Main.processOne(Main.java:632) at com.android.dx.command.dexer.Main.processAllFiles(Main.java:505) at com.android.dx.command.dexer.Main.runMultiDex(Main.java:334) at com.android.dx.command.dexer.Main.run(Main.java:244) at com.android.dx.command.dexer.Main.main(Main.java:215) at com.android.dx.command.Main.main(Main.java:106)
Gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.googleplus_1"
minSdkVersion 10
targetSdkVersion 21
versionCode 1
versionName "1.0"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.0.0'
compile 'com.google.gdata:core:1.47.1'
}
/*
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude group: 'com.google.android.gms', module: 'play-services'
}*/
答案 0 :(得分:3)
为什么要添加com.google.gdata:core:1.47.1
?
如果您在官方网站上阅读http://code.google.com/p/gdata-java-client/,则说:
Android支持:如果您正在为Android开发,并且您要使用的Google API包含在Google Play服务库中, 您应该使用该库以获得最佳性能和体验。 如果您要与Android一起使用的Google API不属于 Google Play服务库,您可以使用Google APIs Client Library for Java,它支持Android 1.5(或更高版本)并提供 其他功能,如OAuth 2.0和Maven。
它建议您使用:
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.api-client:google-api-client:1.18.0-rc'
}
Google Play服务非常重要,不直接使用“整体”依赖关系:
dependencies {
compile 'com.google.android.gms:play-services:7.0.0'
}
选择您需要的模块:
dependencies {
# Google+
com.google.android.gms:play-services-plus:7.0.0
# Google Account Login
com.google.android.gms:play-services-identity:7.0.0
# Google Actions, Base Client Library
com.google.android.gms:play-services-base:7.0.0
# Google App Indexing
com.google.android.gms:play-services-appindexing:7.0.0
# Google Analytics
com.google.android.gms:play-services-analytics:7.0.0
# Google Cast
com.google.android.gms:play-services-cast:7.0.0
# Google Cloud Messaging
com.google.android.gms:play-services-gcm:7.0.0
# Google Drive
com.google.android.gms:play-services-drive:7.0.0
# Google Fit
com.google.android.gms:play-services-fitness:7.0.0
# Google Location, Activity Recognition, and Places
com.google.android.gms:play-services-location:7.0.0
# Google Maps
com.google.android.gms:play-services-maps:7.0.0
# Google Mobile Ads
com.google.android.gms:play-services-ads:7.0.0
# Google Nearby
com.google.android.gms:play-services-nearby:7.0.0
# Google Panorama Viewer
com.google.android.gms:play-services-panorama:7.0.0
# Google Play Game services
com.google.android.gms:play-services-games:7.0.0
# SafetyNet
com.google.android.gms:play-services-safetynet:7.0.0
# Google Wallet
com.google.android.gms:play-services-wallet:7.0.0
# Android Wear
com.google.android.gms:play-services-wearable:7.0.0
}
来源: http://developer.android.com/google/play-services/setup.html