titanium-sdk
titanium-sdk copied to clipboard
Titanium using wrong javac & dx max memory
Describe the bug I am running the following command to compile an app for Android:
ti build -p android -T device
The build process runs a bunch of commands. On the bit it builds the java files, on v7.5.1.GA and older, it run a command like so:
javac -J-Xmx1024M -encoding utf8 -bootclasspath ...
But on v7.5.1.GA and greater (tested on v7.5.2 and v8.0.0), the build command used more memory like so, ignoring the default values of 1GB as mentioned on the docs:
javac -J-Xmx3072M -encoding utf8 -bootclasspath ...
This meant when building my app, I get the following unuseful error message (regardless of log-level):
[ERROR] Failed to compile Java source files:
[ERROR]
[ERROR]
(Side note: It would be good to get more information than just this).
When I tried the javac command manually, I found the error:
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I tried adjusting the the amount of memory used like so:
ti config android.javac.maxmemory 1024M
but it's just ignored it, and still uses 3GB instead.
I solved this issue by adding the following properties to tiapp.xml
<property name="android.javac.maxmemory" type="string">1G</property>
<property name="android.dx.maxmemory" type="string">1G</property>
and the javac command changed correctly.
So the issues are:
- Titanium v7.5.2 and greater does not use the correct memory for javac and dexter
- When adjusting the config, the memory used in the build does not change
- Un-useful error message in console output when build fails (this could be a separate issue)
Environment Titanium SDK version: >=v7.5.2.GA CLI version: v5.2.1 OS: Windows
Logs: No additional messages.
Also mentioned the issue here: https://jira.appcelerator.org/browse/AC-6315
for the CLI it is
appc ti config android.dx.maxMemory "4096M"
with a captial M:
https://docs.appcelerator.com/platform/latest/#!/guide/Titanium_CLI_Options-section-src-37549003_TitaniumCLIOptions-android.dx.maxMemory
in the XML it is correct like this (https://jira.appcelerator.org/browse/TIMOB-26606?focusedCommentId=441403&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-441403)
and both values are raised in 8.1.0: https://github.com/appcelerator/titanium_mobile/blob/master/android/cli/commands/_build.js#L917-L922
Hi thanks. It seems the value has been raised also for v7.5.2 and v8.0. Also if the values have been raised, I think the docs should be updated here: https://docs.appcelerator.com/platform/latest/#!/guide/Titanium_CLI_Options-section-src-37549003_TitaniumCLIOptions-android.dx.maxMemory
I will also try out the CLI change to see if that fixes the issue.
Looks like there is a mistake in the docs.
The docs says it should be android.javac.maxmemory
when it should be ti android.javac.maxMemory
.
The following works fine:
ti android.javac.maxMemory "1G"
ti config android.dx.maxMemory "1G"
However, we should be consistent in what is used in the config & xml.
Either it should be:
- All lower case:
<property name="android.javac.maxmemory" type="string">1G</property>
<property name="android.dx.maxmemory" type="string">1G</property>
ti config android.javac.maxmemory "1G"
ti config android.dx.maxmemory "1G"
- All camel case:
<property name="android.javac.maxMemory" type="string">1G</property>
<property name="android.dx.maxMemory" type="string">1G</property>
ti config android.javac.maxMemory "1G"
ti config android.dx.maxMemory "1G"
Right now it's all over the place: The XML is all lower case:
<property name="android.javac.maxmemory" type="string">1G</property>
<property name="android.dx.maxmemory" type="string">1G</property>
But the config is camel case:
ti config android.javac.maxMemory "1G"
ti config android.dx.maxMemory "1G"
cc @jquick-axway @garymathews