4

I am using Android studio 1.2.2. I've integrated maps 4 work sdk, after this the Build is failing, We are using google play services lib in our project (using only com.google.android.gms.tagmanager.*). Now after integrating googlemaps_sdk_m4b_lib, the build is not getting generated. before to this inte

Tried looking for including only the tagmanager piece of google_play_services_lib but which is not available as a dependency.

Build fails with the following:

:nFarmers:dexDebug AGPBI: {"kind":"SIMPLE","text":"UNEXPECTED TOP-LEVEL ERROR:","position":{},"original":"UNEXPECTED TOP-LEVEL ERROR:"} AGPBI: {"kind":"SIMPLE","text":"java.lang.OutOfMemoryError: GC overhead limit exceeded","position":{},"original":"java.lang.OutOfMemoryError: GC overhead limit exceeded"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.cf.cst.ConstantPoolParser.parseUtf8(ConstantPoolParser.java:371)","position":{},"original":"\tat com.android.dx.cf.cst.ConstantPoolParser.parseUtf8(ConstantPoolParser.java:371)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.cf.cst.ConstantPoolParser.parse0(ConstantPoolParser.java:262)","position":{},"original":"\tat com.android.dx.cf.cst.ConstantPoolParser.parse0(ConstantPoolParser.java:262)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.cf.cst.ConstantPoolParser.parse(ConstantPoolParser.java:150)","position":{},"original":"\tat com.android.dx.cf.cst.ConstantPoolParser.parse(ConstantPoolParser.java:150)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.cf.cst.ConstantPoolParser.parseIfNecessary(ConstantPoolParser.java:124)","position":{},"original":"\tat com.android.dx.cf.cst.ConstantPoolParser.parseIfNecessary(ConstantPoolParser.java:124)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.cf.cst.ConstantPoolParser.getPool(ConstantPoolParser.java:115)","position":{},"original":"\tat com.android.dx.cf.cst.ConstantPoolParser.getPool(ConstantPoolParser.java:115)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:482)","position":{},"original":"\tat com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:482)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)","position":{},"original":"\tat com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)","position":{},"original":"\tat com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)","position":{},"original":"\tat com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.parseClass(Main.java:764)","position":{},"original":"\tat com.android.dx.command.dexer.Main.parseClass(Main.java:764)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.access$1500(Main.java:85)","position":{},"original":"\tat com.android.dx.command.dexer.Main.access$1500(Main.java:85)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1684)","position":{},"original":"\tat com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1684)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.processClass(Main.java:749)","position":{},"original":"\tat com.android.dx.command.dexer.Main.processClass(Main.java:749)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.processFileBytes(Main.java:718)","position":{},"original":"\tat com.android.dx.command.dexer.Main.processFileBytes(Main.java:718)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.access$1200(Main.java:85)","position":{},"original":"\tat com.android.dx.command.dexer.Main.access$1200(Main.java:85)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1645)","position":{},"original":"\tat com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1645)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)","position":{},"original":"\tat com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)","position":{},"original":"\tat com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)","position":{},"original":"\tat com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.processOne(Main.java:672)","position":{},"original":"\tat com.android.dx.command.dexer.Main.processOne(Main.java:672)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.processAllFiles(Main.java:569)","position":{},"original":"\tat com.android.dx.command.dexer.Main.processAllFiles(Main.java:569)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.runMultiDex(Main.java:366)","position":{},"original":"\tat com.android.dx.command.dexer.Main.runMultiDex(Main.java:366)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.run(Main.java:275)","position":{},"original":"\tat com.android.dx.command.dexer.Main.run(Main.java:275)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.main(Main.java:245)","position":{},"original":"\tat com.android.dx.command.dexer.Main.main(Main.java:245)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.Main.main(Main.java:106)","position":{},"original":"\tat com.android.dx.command.Main.main(Main.java:106)"}

FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':nFarmers:dexDebug'.

    com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/bin/java'' finished with non-zero exit value 3

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1 mins 24.059 secs

My app's build.gradle file

    apply plugin: 'android'

    dependencies {
        compile fileTree(dir: 'libs', include: '*.jar')
        compile 'com.android.support:multidex:1.0.0'
        compile project(':Marketing')
        compile project(':android-pdfview')
        compile project(':Volley')
        compile project(':googlemaps_sdk_m4b_lib')
        compile 'com.google.android.gms:play-services:7.5.0'
    }

    android {
        compileSdkVersion 22
        buildToolsVersion "23.0.0 rc2"
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        jniLibs.srcDirs = ['jniLibs']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }

    // Move the tests to tests/java, tests/res, etc...
    instrumentTest.setRoot('tests')

    // Move the build types to build-types/<type>
    // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
    // This moves them out of them default location under src/<type>/... which would
    // conflict with src/ being used by the main source set.
    // Adding new build types or product flavors should be accompanied
    // by a similar customization.
    debug.setRoot('build-types/debug')
    release.setRoot('build-types/release')
}
defaultConfig {
    minSdkVersion 16
    targetSdkVersion 22
    // Enabling multidex support.
    multiDexEnabled true
}
buildTypes {
    debug {
        multiDexKeepFile file('main-dex-list.txt')
        debuggable true
        proguardFile '/Users/path/to/proguard-project.txt'
    }
    release {
        multiDexKeepFile file('main-dex-list.txt')
    }
}

productFlavors {
}
dexOptions {
}
aaptOptions {
    useNewCruncher true
}
configurations{
    all*.exclude group: 'com.android.support', module:'multidex'
    all*.exclude group: 'com.android.support', module: 'support-v4'
}

}
lmgonzalves
  • 6,518
  • 3
  • 22
  • 41
ktir
  • 43
  • 1
  • 5

1 Answers1

16

Try adding

dexOptions{        
    incremental true 
    javaMaxHeapSize "4g" 
}
charliebeckwith
  • 1,449
  • 11
  • 29
  • 1
    Thanks @Solarnum, this resolved my issue. does this have any impact in the build process? – ktir Jun 14 '15 at 06:59
  • 1
    Yup. Incremental tells gradle not to build unmodified files that have already been built previously, which in theory lowers compile time and memory strain. The other option just increases the size of the heap the compiler is allotted. It has an impact on the build process in so much that in your case makes it succeed, lol but really it's just bending the rules andmake them more permissive. The error that was killing things for you was GC Overhead. – charliebeckwith Jun 14 '15 at 08:04
  • 1
    Hi, i tried using this but I still have the same error. I was wondering if the problem as well is the GC Overhead? and what it causes? mine is " finished with non-zero exit value 2" – Kairi San Jan 20 '16 at 01:02
  • 1
    @KairiSan I believe that that is not a memory issue, rather that you've hit the 65K method limit. Try removing unnecessary libraries and if you're sure you need everything, try using MultiDex lib – charliebeckwith Jan 20 '16 at 18:38
  • @Solarnum Also, try adding 'multiDexEnabled = true' under defaultConfig – denizen Feb 25 '16 at 22:08
  • the incremental property there appears to be deprecated with recent versions of the dex library as it has no effect on the build process now. Simply increasing the heap size to prevent GC overheads solves the problem – Akah Feb 09 '17 at 22:29