I’ve been at this on and off for a solid week now and there’s absolutely no indication as to why this is happening. Not happening on any of our programmers machines, just my laptop which I was wanting to be able to use to build android builds on the weekends when everyone is off. So a big thanks in advance to anyone that can help shed some light on this
Starting with a completely blank project when I try to build the .APK I get this:
When I try to build any other project I get the same message. Now before posting this and daring to trouble any fine folks that would be so kind as to help me I have tried absolutely everything.
I downgraded my Android SDK to R21
Moved the Android SDK to the root of C:\
I am using the x86 version of Java and Android SDKI have tried JRE6 and JRE7 and JDK7. Uninstalling each one and installing them separately
I have set my JAVA_HOME variable in my system environment variables
I have set _JAVA_OPTIONS to -Xmx1024M and -Xmx512M but it completely ignores this everytime regardless of if I set this as a user variable or a system variable or both
Tried copying the java exe’s from system 32 to sysWOW64
Tried in Unity 3.5.7f6 free and Unity 4.1.3f3 - same error
Tried installing and using the 64 bit Java SDK and Runtime Environment
Tried building with mono open and then closing mono and building again
Tried creating a new Android Virtual device with 2GB of internal memory and an 8GB SD card
When I got into the Tools directory and run .\android.bat list target -c
I get this:
So the damned things working on it’s own but in Unity it Picks up -Xmx2048M and I have no idea why or where ti is getting that from. When I run java -version from the command line I get this:
At this point I don’t even know how to trouble shoot this as nothing I do is making a difference to this error and it is always there. Anything you guys can offer for advice would be hugely appreciated, even to put me on the path to tracking down why this is happening or other things to check that I might have overlooked. thanks
Hey Cake, thanks for the reply and the link… The problem is clearly a java issue but I’m only experiencing it in conjunction to Unity. As you can see in my OP I have tried to run tests with just Java and they all come back fine… I’ve learned from your handy link there that JRE 32 won’t work with a -Xmx value over 1.5GB and so that would explain why Java is having a hissy fit. What I can’t explain though is why, only when launched through Unity, Java is ignoring my system wide Environmental variable of _JAVA_OPTIONS: -Xmx1024M and is instead running with a value of -Xmx2048M. Only through Unity, with anything else it picks up my variable of 1024M and run with that.
Hmm… that is odd. Sadly, I don’t know enough about Unity/Java combo to help.
Are you on a 64bit OS? It might be worth trying out 64bit Java. (That is a complete shot in the dark suggestion, I don’t even know if Unity would even support it.)
I’ve just read everywhere that Unity and 64bit Java just don’t mix. Mainly that the 64 bit Android SDK will not work but have read the same thing about 64bit Java. I believe I had it installed initially and then took it off… Can give it another go, thanks for the tip
Tried using the 64 bit JDK but it just spits this out: Error building Player: Win32Exception: ApplicationName=‘java.exe’, CommandLine=‘-Xmx1024M -Dcom.android.sdkmanager.toolsdir=“C:/GameDev/Engines/adt-bundle-windows-x86-20130522/sdk\tools” -Dfile.encoding=UTF8 -jar “C:/Program Files (x86)/Unity/Editor/Data/BuildTargetTools/AndroidPlayer\sdktools.jar” -’
The kick in the pants with the above error message is with a 64bit JDK it see’s the -Xmx1024M env variable. Ugh, reinstalling the 32 bit one now hoping it wuold have cleared wherever that 2048 var was coming from.
Tried making a new AVD and made sure that Mono was closed… Same error there too
Ubelieavable, this problem is STILL occurring… I did a registry search and low and behold at Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Session Manager\Environment\ I found _JAVA_OPTIONS -Xmx2048M and so of course I changed it to -Xmx1024M but Unity keeps on spitting out the message that it picked up -Xmx1024M… I{ have NO idea where it is getting this from, it isn’t anywhere in my registry, I searched every file in Unity’s directory, in the Android SDK’s directory and in my projects directory and no where in any of these is there any reference to Xmx2048 … There’s a lot to 386 and some to 1024 but nothing telling the SDK to use that variable…
Again this happens with unity 4 and 3.5 and I have no idea in hell as to where to go from here to fix this
God, what a kick in the nuts… The problem was ObjectDock all along… I have no idea why it would be causing this as it’s just a dock with shortcuts on it but if Unity is started by clicking on a Dock Icon it causes this mess above… Run Unity by clicking on the .exe in explorer and everything works perfectly… UGGHHHHH
Problem cropped up again today forcing me to realize it wasn’t objectdock afterall. I had a unity shortcut pinned to my start menu favorites and the same problem happened when running from there… The only way to ensure this problem doesn’t occur is to run the .exe directly.