Akeshwar Akeshwar - 2 months ago 13
Java Question

Implementing Google directory API in an android app

I'm following this link https://developers.google.com/admin-sdk/directory/v1/quickstart/android to use the google directory API. I'm new to android developement and followed the steps there. At the end, while running the app, I was getting this error:


Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 2


I fixed it by putting
multiDexEnabled true
in the
defaultConfig
at app level build.gradle. Next, when I tried running the app, it went out of memory after taking about 10 minutes. Here's the complete log:


:app:dexDebug
Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space
Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space
Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space
3 errors; aborting
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 1
Information:BUILD FAILED
Information:Total time: 9 mins 46.138 secs
Information:1 error
Information:0 warnings
Information:See complete output in console


Here is my app level build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.google.samples.quickstart.signin"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'LICENSE.txt'
}
// Resolve dependency differences between app and tests
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:22.2.0'
}
productFlavors {
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.google.android.gms:play-services-plus:8.1.0'
// UiAutomatorTesting
androidTestCompile 'com.android.support.test:runner:0.2'
androidTestCompile 'com.android.support.test:rules:0.2'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.0'
androidTestCompile 'com.android.support:support-annotations:23.0.1'
}


What am I doing wrong?

Answer

Adding

android {
    dexOptions {
        javaMaxHeapSize "4g"
    }
}

to build.gradle made the code working as we increased the maximum size of the heap.

Comments