Change gradle's temp directory when used with Android Studio
<p>Using Gradle 2.10 within Android Studio, I'm having some problems with the amount of space on my root partition combined with the fact that gradle produces quite a lot of tmp files.
I'd like to change my gradle tmp file to ~/tmp, but so far haven't managed to do so.</p>

<p>Things I've tried:</p>

<pre><code>$ export TEMP=TMP=TMPDIR=&lt;home folder&gt;/tmp
$ studio &amp;
</code></pre>

<p>No success, gradle still uses <code>/tmp</code>.</p>

<p>Modify java.io.tmpdir via Gradle's jvmargs in gradle.properties:</p>

<pre><code>org.gradle.jvmargs=-Xmx2048M -Djava.io.tmpdir=&lt;home folder&gt;/tmp
</code></pre>

<p>Still no success.</p>

<p>Of course, my root issue is the lack of space on <code>/</code>, and I have managed to get it usable for some time more, but unless I completely reconfigured lots of stuff on my machine I will run short from time to time. Since my home directory is mounted on a 1 TB partition it would be nice to use it for tmp files instead.</p>

<p>Actually, if there's a solution system-wide that also affects gradle, that would be just as good or even better. Any ideas?</p>

<hr>

<p>UPDATE: This does not seem to actually be about / being full, even though "No space left on device" is what's reported. After making sure my / partition has lots of space this still happened.</p>

<p>After searching some more I found <a href="http://www.out4mind.com/en/android-studio-updates-error-linux/" rel="nofollow">http://www.out4mind.com/en/android-studio-updates-error-linux/</a> which suggests setting the tmpdir from studio64.vmoptions:</p>

<pre><code>$ echo "-Djava.io.tmpdir=&lt;&lt;&lt;home folder&gt;&gt;&gt;/tmp" &gt;&gt; ~/.AndroidStudio&lt;&lt;&lt;version&gt;&gt;&gt;/studio64.vmoptions
</code></pre>

<p>I tried that, but after restarting AS, the same error persists. I also verified using</p>

<p>jps -lvm </p>

<p>that my java.io.tmpdir is in fact set. Still no success though.</p>

<p>I'm starting to think that this might be NDK related because my project has native code and I do use the gradle-experimental plugin with NDK support. Question is which device is full, is there a RAM disk involved when invoking the native compiler?</p>