clojure-android / neko

The Clojure/Android Toolkit
Other
297 stars 36 forks source link

java.lang.OutOfMemoryError when creating dex #31

Closed thrawn-a-D closed 10 years ago

thrawn-a-D commented 10 years ago

First of all, thanks for the great and constant work you put in neko. I wanted to get in touch with android development in clojure. But after creating a project as described, using:

$> lein droid new clojuroid org.stuff.clojuroid :activity MyActivity :target-sdk 19 :app-name ClojureMeetsAndroid

I try to build it with lein droid build and get an OutOfMemory exception:

Creating DEX....

UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: Java heap space
    at com.android.dx.cf.code.Frame.copy(Frame.java:98)
    at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:697)
    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)

I tried different neko versions, increasing jvm memory, cleaned up my profiles.clj. I even tried those steps on different machines. Non of my actions could prevent this from happening.

What am I doing wrong?

I use: java 1.7.0_21, neko 3.x lein-droid 0.2.3 leiningen 2.2.0

alexander-yakushev commented 10 years ago

Please uncomment :dex-opts ["-JXmx4096M"] line in your project.clj. This should fix the issue.

Sorry, I haven't noticed that you already tried increasing JVM memory. Maybe then try uncommenting :force-dex-optimize true, but it is pretty weird that 4GB of memory is not enough to build a sample project.

thrawn-a-D commented 10 years ago

Wow, now that is a quick response time :+1: Thanks for your hint! I was using the leiningens :jvm-opts and overlook the comments related to OutOfMemory issues. After removing the jvm-opts and setting the :dex-opts, it finally created a dex file.

Thank you and keep up the great work.

alexander-yakushev commented 10 years ago

You are welcome! Increasing memory of Leiningen didn't work becase dx (dex) is an external utility, and it itself needs more memory, not the Leiningen.