Hi,
I'm working on an Air mobile game that uses ANE on iOS and Android. I'm in the process of creating a new ANE and face a problem on the Android side.
My ANE requires an external framework (Burstly, http://burstly.com). If I just link the Android project to Burstly's .jar file, I get errors in "adb logcat", like:
I/dalvikvm(16074): Could not find method com.burstly.lib.BurstlySdk.init, referenced from method com.freshplanet.burstly.functions.InitBurstlyFunction.call
In order to include Burstly's files in my own .jar, I unzip Burstly's .jar file and repackage them with my compiled code in a unique .jar (following advice on http://stackoverflow.com/questions/7732742/air-3-native-extensions-for -android-can-i-how-to-include-3rd-party-libraries).
Problem: Burstly's SDK includes thousands of files. It doesn't create any trouble when packaging the ANE, but when I try to package the Air application, I get the following error:
dx tool failed:
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: Java heap space
at com.android.dx.util.IntList.<init>(IntList.java:87)
at com.android.dx.rop.code.RopMethod.calcPredecessors(RopMethod.java:174 )
at com.android.dx.rop.code.RopMethod.labelToPredecessors(RopMethod.java: 95)
at com.android.dx.ssa.back.IdenticalBlockCombiner.process(IdenticalBlock Combiner.java:74)
at com.android.dx.ssa.back.SsaToRop.convert(SsaToRop.java:132)
at com.android.dx.ssa.back.SsaToRop.convertToRopMethod(SsaToRop.java:76)
at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:103)
at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:74)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:2 69)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:131)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:85)
at com.android.dx.command.dexer.Main.processClass(Main.java:299)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:278)
at com.android.dx.command.dexer.Main.access$100(Main.java:56)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpen er.java:244)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.j ava:130)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java :108)
at com.android.dx.command.dexer.Main.processOne(Main.java:247)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:183)
at com.android.dx.command.dexer.Main.run(Main.java:139)
at com.android.dx.command.dexer.Main.main(Main.java:120)
at com.android.dx.command.Main.main(Main.java:89)
I read that the solution to eliminate this error is to give Java the parameters "-Xms...M -Xmx...M", with "..." being a high-enough number. Note that I'm working on a machine with 8GB of RAM. I tried to package the app in command line to be able to pass these parameters:
/usr/bin/java -Xms512M -Xmx4096M -jar "/Applications/Adobe Flash Builder 4.6/sdks/4.6.0air31/lib/adt.jar" -package -target apk -storetype pkcs12 -keystore [...].p12 Main.apk Main-app.xml Main.swf -extdir "/Users/alex/Documents/Adobe Flash Builder 4.6/.metadata/.plugins/com.adobe.flexbuilder.project.ui/ANEFiles/fron t-end-mobile/com.adobe.flexide.multiplatform.ios.platform"
But when I run a "ps -ef | grep java", I can see that adt runs another Java program (dx) without transmitting my -Xms -Xmx parameters:
/usr/bin/java -jar /Applications/Adobe Flash Builder 4.6/sdks/4.6.0air31/lib/android/bin/dx.jar --dex --output=/private/var/folders/t9/3kw74cx14nv2xg9tgmx9m1jc0000gp/T/b57 57d93-1e93-439c-8f6d-c93e4933f6f1/outputDEX.dex [... bunch of jars]
Any idea to solve this issue?
Thanks
Alex
I solved my issue by setting the _JAVA_OPTIONS environment variable. (Note: there are two underscores)
I added the following line to my .bash_profile:
export _JAVA_OPTIONS="-Xms1024m -Xmx4096m -XX:MaxPermSize=512m"
Now everytime a Java program is launched from the command line, I see the following message:
Picked up _JAVA_OPTIONS: -Xms1024m -Xmx4096m -XX:MaxPermSize=512m
And my application packaging runs just fine now. ![]()
I still have an issue though: this trick solved the problem for packaging the app from the command line, but the _JAVA_OPTIONS are not picked up when packaging from Flash Builder, so it still crashes there.
Note that my Adobe Flash Builder 4.6.ini contains the following options:
-Xms512m
-Xmx1676m
-XX:MaxPermSize=512m
-XX:PermSize=64m
1676m is the highest number I can put before Flash Builder refuses to launch. I'm not sure if these parameters are actually passed to the VM that runs de dx.jar program, or if it's just for the ActionScript compiler. But anyway my app packaging still crashes in Flash Builder.
If someone knows a way to force Flash Builder to pickup the _JAVA_OPTIONS set in the command line, let me know :-)
Thanks
Alex
North America
Europe, Middle East and Africa
Asia Pacific