Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven Doesn't Seem to Pass Arguments to JVM

I'm trying to compile an Android application that depends on OrmLite and whatever I do I still receive the OutOfMemory error.

The reason why I think Maven doesn't pass any arguments regarding the heap size is I can only see the following in its output:

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -jar /Users/mikhail.borozdin/android-sdk-macosx/platform-tools/lib/dx.jar --dex --output=/Users/mikhail.borozdin/Documents/workspace/AndroidOrmLiteTest/target/classes.dex

How did I try to pass arguments to JVM?

  • export MAVEN_OPTS=-Xmx2048m
  • mvn -X install -DargLine="-Xmx2048m"
  • Setting for my plug-in in pom.xml
  • Setting for my plug-in in pom.xml

Neither of these worked.

like image 383
Mike Borozdin Avatar asked Nov 23 '25 14:11

Mike Borozdin


1 Answers

If the project you're building is using the android-maven-plugin, you want to set the dex mojo configuration in the maven pom.xml file, eg:

<dex>
  <jvmArguments>
    <jvmArgument>-Xms256m</jvmArgument>
    <jvmArgument>-Xmx512m</jvmArgument>
  </jvmArguments>
</dex>

Here's an example from a complete pom.xml file:

https://github.com/rtyley/agit/blob/a014c970/pom.xml#L116-121

Note that the specific xml for dex configuration evolved a fair bit in the run-up to release of android-maven-plugin version 3.0.0 (which has lots of other crucial improvements) - I would recommend ensuring that you are using this version and that the configuration is definitely using the <dex> node.

The android-maven-plugin will use a 1GB heap by default in versions post-v3.0.0 (not yet released at the time of writing).

like image 199
Roberto Tyley Avatar answered Nov 26 '25 03:11

Roberto Tyley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!