我正在尝试为Android安装google api java客户端
根据documentation,应该很容易, 只需将这两行添加到build.gradle文件中:
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.api-client:google-api-client:1.20.0'
}
这是我的构建gradle文件的样子:
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.journee"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.1-alpha1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.android.support:design:22.2.1'
compile 'com.google.api-client:google-api-client-android:1.20.0' exclude module: 'httpclient'
}
但是当我尝试运行它时出现错误:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
遵循此post:
我试图清理,并将以下行添加到我的文件中:
defaultConfig {
multiDexEnabled true
}
但是现在构建需要很长时间,但仍然会出现错误:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.