I'm going to build realm. So run this command in command prompt:
gradlew assemble
But I got this error:
* What went wrong:
Execution failed for task ':realm-library:downloadCore'.
> Java heap space
Windows 7 64-bit Ultimate
Gradle 3.1
cygwin 2.5.2 64bit
Installed JDKs and JREs:
64bit:
jdk1.8.0_121
jre1.8.0_121
32bit:
jdk1.8.0_121
jre1.8.0_121
jdk1.7.0_80
jre7
jdk1.6.0_45
jre6
Used java version in Environment Variables: 1.8.0_121

Well it claims it ran out of memory, you can try adding more memory if you have a build.gradle where you can put this:
dexOptions{
javaMaxHeapSize "4g"
}
Although considering this is not dex, i'm not sure if it helps
@Zhuinden I tested this before, and didn't help.
Even change
org.gradle.jvmargs=-XX:MaxPermSize=512m
From
\realm\realm-java\gradle.properties
To something more
Or change
org.gradle.jvmargs=-Xms512m -Xmx2048m
From
\realm\realm-java\realm\gradle.properties
To something more
Or
Put gradle.properties under
\realm\realm-java\realm
With this content:
org.gradle.jvmargs=-Xms2048m -Xmx4048m
Didn't help.
But when I set
GRADLE_OPTS=-Xmx2048m
In Environment Variables, I get this error:
Could not reserve enough space for 2097152
Make sure you close Chrome and other memory intensive stuff for this process to work
From the screenshot I assume that you are using Windows. We have tried to build under Windows so I can't tell if it's a Windows issue or not. Moreover, building Realm requires Android NDK which in the past wasn't working that well under Windows. My recommendation is that you install Linux in a virtual machine and try to build using that.
Switch to Windows 10 and use the built-in Linux support might be another option. Again, we haven't tried that.
@Zhuinden I have 32GB memory on my machine; And about 20GB is free. @kneth I'll try these solution too...
Can it be that you are using the 32 bit version of the JVM? The number reported indicated that you are not allowed to allocate more than 2 GB.
Btw, building Realm Java requires NDK r10e. Previously the NDK had issues on Windows: https://github.com/android-ndk/ndk/issues/139
@kneth Memory heap problem caused by JDK 32bit. I changed it to JDK 64bit and I get this error now:

I downloaded CMake from Android Studio.
It could be the same problem with https://github.com/taka-no-me/android-cmake/issues/94
@Drjacky would you please try to modify the ./realm/realm-library/src/main/cpp/android.toolchain.cmake as it is described here and let us know the results? I don't have a windows machine right now so i cannot verify it :(
Thanks!
@beeender After those changes: I got this:

@Drjacky Make sure the javah is in your system's PATH so cmake can find it to generate jni header files from java class.
@beeender It's exist!

hmmm, maybe it is trying to find the javah by JAVA_HOME. Can you try to set the JAVA_HOME to your JDK home?
@beeender This is my whole Environment Variables:

Does C:\Program Files\Java\jdk1.8.0_121\bin\javah.exe exist?
@beeender Yes.

It is very strange. Probably caused by the cmake doesn't play well with windows path separator.
So maybe you can try to handcode the javah path in ./realm/realm-library/src/main/cpp/android.toolchain.cmake. Before line 10 else(), something like:
elseif (EXISTS "C:/Program Files/Java/jdk1.8.0_121/bin/javah.exe")
set(Java_JAVAH_EXECUTABLE "C:/Program Files/Java/jdk1.8.0_121/bin/javah.exe")
You might need to remove the line 6-7 since you actually have the JAVA_HOME set.
Also, if it doesn't work, try to change the path separator to \\.
or maybe you only need to add .exe to line 6-7
@beeender I coudn't find that line. This is my android.toolchain.cmake
*Note: Attaching ZIP file failed. So I changed text file extension to JPG. Please download this file and remove JPG extension.
Link

uh ... Really sorry, I put a wrong file path there. It should be ./realm/realm-library/src/main/cpp/CMakeLists.txt
@beeender Adding .exe to javah didn't help. But when I added another elseif, javah not found error gone, but this error:

It might be a cmake bug which is similar to https://llvm.org/bugs/show_bug.cgi?id=27226 ...
I don't have immediate idea right now ... I suggest you to try compile it under linux (virtual machine maybe?) or maybe you can try with build it in cygwin? It might solve it but i am not sure.
I will mark this as an low priority issue. And it will not be solved soon since no one is using windows in the team. Sorry :(
Folding this into the original issue about Windows support: #911
Most helpful comment
@beeender Yes.
