Question

I am using Android Studio, and am trying to import dynamodb library by importing aws-java-sdk. However, adding this dependency would cause my build to fail for GC overhead limit exceeded. What went wrong?

Perhaps aws-java-sdk is not the right thing to use here?

My gradle file:

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.android.support:support-v4:19.0.0'
    compile 'org.apache.commons:commons-lang3:3.3'
    compile 'com.google.guava:guava:16.0.1'
    compile 'joda-time:joda-time:2.3'
    compile 'com.amazonaws:aws-java-sdk:+'
    compile fileTree(dir: 'libs', include: ['*.jar'])

    compile "org.mockito:mockito-all:1.9.5"
}

And this is the stack track:

Information:Gradle tasks [:backagen:assembleDebug]
Information:UNEXPECTED TOP-LEVEL ERROR:
Information:java.lang.OutOfMemoryError: GC overhead limit exceeded
Information:    at com.android.dx.util.FixedSizeList.<init>(FixedSizeList.java:38)
Information:    at com.android.dx.rop.code.RegisterSpecList.<init>(RegisterSpecList.java:102)
Information:    at com.android.dx.cf.code.RopperMachine.getSources(RopperMachine.java:668)
Information:    at com.android.dx.cf.code.RopperMachine.run(RopperMachine.java:288)
Information:    at com.android.dx.cf.code.Simulator$SimVisitor.visitConstant(Simulator.java:691)
Information:    at com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:772)
Information:    at com.android.dx.cf.code.Simulator.simulate(Simulator.java:94)
Information:    at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:698)
Information:    at com.android.dx.cf.code.Ropper.doit(Ropper.java:653)
Information:    at com.android.dx.cf.code.Ropper.convert(Ropper.java:266)
Information:    at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:282)
Information:    at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:139)
Information:    at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:94)
Information:    at com.android.dx.command.dexer.Main.processClass(Main.java:682)
Information:    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
Information:    at com.android.dx.command.dexer.Main.access$600(Main.java:78)
Information:    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
Information:    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
Information:    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
Information:    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
Information:    at com.android.dx.command.dexer.Main.processOne(Main.java:596)
Information:    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
Information:    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
Information:    at com.android.dx.command.dexer.Main.run(Main.java:230)
Information:    at com.android.dx.command.dexer.Main.main(Main.java:199)
Information:    at com.android.dx.command.Main.main(Main.java:103)
Information:1 error
Information:0 warnings
Information:See complete output in console
Error:Execution failed for task ':backagen:preDexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /Applications/Android Studio.app/sdk/build-tools/android-4.4.2/dx --dex --output /Users/samwong/AndroidStudioProjects/BackAgen/backagen/build/pre-dexed/debug/aws-java-sdk-1.7.5-131e66c92e708a5c19c92b04dbc3bf0a71acb816.jar /Users/samwong/.gradle/caches/modules-2/files-2.1/com.amazonaws/aws-java-sdk/1.7.5/650f07e69b071cbf41c32d4ea35fd6bbba8e6793/aws-java-sdk-1.7.5.jar
  Error Code:
    3
  Output:
    UNEXPECTED TOP-LEVEL ERROR:
    java.lang.OutOfMemoryError: GC overhead limit exceeded
        at com.android.dx.util.FixedSizeList.<init>(FixedSizeList.java:38)
        at com.android.dx.rop.code.RegisterSpecList.<init>(RegisterSpecList.java:102)
        at com.android.dx.cf.code.RopperMachine.getSources(RopperMachine.java:668)
        at com.android.dx.cf.code.RopperMachine.run(RopperMachine.java:288)
        at com.android.dx.cf.code.Simulator$SimVisitor.visitConstant(Simulator.java:691)
        at com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:772)
        at com.android.dx.cf.code.Simulator.simulate(Simulator.java:94)
        at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:698)
        at com.android.dx.cf.code.Ropper.doit(Ropper.java:653)
        at com.android.dx.cf.code.Ropper.convert(Ropper.java:266)
        at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:282)
        at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:139)
        at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:94)
        at com.android.dx.command.dexer.Main.processClass(Main.java:682)
        at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
        at com.android.dx.command.dexer.Main.access$600(Main.java:78)
        at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
        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:596)
        at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
        at com.android.dx.command.dexer.Main.run(Main.java:230)
        at com.android.dx.command.dexer.Main.main(Main.java:199)
        at com.android.dx.command.Main.main(Main.java:103)
Was it helpful?

Solution

There is a separate android-sdk that's for android development.

This is not in maven currently, so you'll need to download it form http://aws.amazon.com/sdkforandroid/ , then put the required jars inside libs/

But that's not all. If you import every jar file, it will throw a cryptic multiple dex files define' error when you run it. To understand which jars are needed, see http://docs.aws.amazon.com/mobile/sdkforandroid/gsg/Welcome.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top