How can I build my Gradle project using a Windows JDK from Ubuntu on Windows?
Just to make sure I didn't miss anything obvious, I downloaded Android Studio (which contains JDK, or rather, minimal set of Java tools to build Android projects) for Windows and Linux and installed them to 2 different directories: Windows version in C:\Program Files\Android\Android Studio
and Linux version in ~/android-studio
.
Inside WSL, I first set JAVA_HOME
to C:\Program Files\Android\Android Studio\jre
and ran gradlew
. It gave me invalid directory
error message.
Next, I set JAVA_HOME
to ~/android-studio/jre
. Everything worked as expected.
And then I copied Android Studio for Windows to ~/android-studio-windows
and set JAVA_HOME
to ~/android-studio-windows/jre
. It gave me the same invalid directory
error message, so I think WSL isn't able to use Windows tools as they are (well, at least not for the moment).
So, if your goal is to use gradle in WSL, I think you need to install OpenJDK for Linux (or something similar) inside WSL.