Compile JUCE-Android project on Windows


Hi, I know many people don't like Linux, and some of them don't have OSX machine, so how to compile JUCE-Android project on Windows is their desires. I found an easy way to accomplish it. If this little tip could help you, it'll be my pleasure.

1. Setup Compile Envionment On Windows (7)

1.1 Download and install/unzip JDK, Android SDK, NDK to your local disk. For example, SDK and NDK locate in (you may change the bold texts to adapt your situation):



1.2 Add envionment variables to Windows. For example:

PATH: %JAVA_HOME%\bin;C:\Users\yourLoginName\SDKs\ant\bin;C:\Users\yourLoginName\SDKs\android-sdk\tools;C:\Users\yourLoginName\SDKs\android-ndk;C:\Users\yourLoginName\SDKs\android-ndk\toolchains\arm-linux-androideabi-4.8\prebuilt\windows-x86_64\bin

1.3 Open the SDK Manager which locates in Android SDK dir, download and install Tools, API, etc. The API version must matching the "Minumum SDK version" which you will find it in Introjucer's Android project settings later on.

Get the things above done once and for ever, there is no need doing these boring grinds again if the stupid Windows works normal.

2. Create Android project in Introjucer

Just create, do some settings and save the project.

3. Modify the build.xml

3.1 The file build.xml locates in "..\yourProject\Builds\Android". Using a text editor application open it, search for "${ndk.dir}/ndk-build",  replace to "${ndk.dir}/ndk-build.cmd". There are 2 places need to be modified: line 9 and line 23. This is the most important step for compile the JUCE-Android project on Windows.

However, I hope JUCE team could add few lines, using a JUCE platform MACRO and a String object to replace the  literal "${ndk.dir}/ndk-build" in "..\extras\Introjucer\Source\Project Saving\jucer_ProjectExport_Android.h", line 617 and 646. If so, it'd very helpful for all JUCE Windows-Android user. I know Windows is a bad thing for Android though...

3.2 Save build.xml in the text editor. Don't save the project again in Introjucer since it'll generate the build.xml again.

4. Compile

4.1 Run "cmd" (Windows commad-line window), into  "..\yourProject\Builds\Android". You could do this easily from the file browser: don't select any file or dir, shift+right click, in the popup menu select "Into command-line window from here" (maybe another words since my Windows OS is non-English version).

4.2 In the cmd window, type: "ant debug", or "ant release". After a while, the Android APK file of your project will be generated in "..\Builds\Android\bin". 

5. Enjoy!


Thank you very much for posting this! This post made it a breeze figuring out how to build a JUCE Android app from the command line. I had no idea it was so easy to do. 


Glad to hear you built your JUCE-Android project on Windows. Congratulations!


Hi, I tried your approach but I get this output while trying ant release:


c:\Users\Aros\C++ libs\JUCE-master\examples\Demo\Builds\Android\build.xml:32: Ca
nnot find C:\Users\Aros\SDKs\android-sdk\tools\ant\build.xml imported from c:\Us
ers\Aros\C++ libs\JUCE-master\examples\Demo\Builds\Android\build.xml


Well, of course it cannot. I have installed android-sdk somewhere else. But how do I explain the build to look for it somewhere else?

In build.xml there's this line (32):

<import file="${sdk.dir}/tools/ant/build.xml"/>


Well, how do I set ${sdk.dir} to point to my android-sdk folder?





You can set the SDK path in the Introjucer: in Introjucer's global preferences (Tools -> Global Preferences...) or by clicking on the Android project in the Config tab and modifying the Android SDK Path/Android NDK Path settings on the RHS of the window.


Sorry, I have seen this option in Introjucer, but somehow I read it/understood it as JDK.


Anyway now, it tries to compile the Demo, but ends up with:


[exec] jni/../../../Source/../JuceLibraryCode/modules/juce_audio_processors/../../../../../modules/juce_audio_processors/../juce_gui_basics/../juce_graphics/juce_graphics.h:105:60: fatal error: contexts/juce_LowLevelGraphicsSoftwareRenderer.h: No such file or directory
[exec]  #include "contexts/juce_LowLevelGraphicsSoftwareRenderer.h"
[exec]                                                             ^
[exec] compilation terminated.


I cloned the repo again, so it should be the latest version.


I found a solution here:


It seems I am in the very same situation as robiwan was and adding -I "../../../../modules/juce_graphics" -I "../../../../modules/juce_data_structures" to the extra compiler flag solved this problem (I don't think that is my fault, maybe someone should look at it), but there is another while compiling juce_opengl.cpp:


[exec] [armeabi] Compile++ thumb: juce_jni <= juce_opengl.cpp
[exec] In file included from jni/../../../../../modules/juce_graphics/image_formats/juce_PNGLoader.cpp:266:0,
[exec]                  from jni/../../../../../modules/juce_graphics/juce_graphics.cpp:118:
[exec] jni/../../../../../modules/juce_graphics/image_formats/pnglib/png.c: In function 'int juce::pnglibNamespace::png_icc_profile_error(png_const_structrp, png_colorspacerp, juce::pnglibNamespace::png_const_charp, juce::pnglibNamespace::png_alloc_size_t, juce::pnglibNamespace::png_const_charp)':
[exec] jni/../../../../../modules/juce_graphics/image_formats/pnglib/png.c:1734:1: internal compiler error: Segmentation fault
[exec]  }
[exec]  ^
[exec] Please submit a full bug report,
[exec] with preprocessed source if appropriate.
[exec] See <> for instructions.


Now that is very strange. Compiler segmentation fault? Well well....


I tried again and it built the apk with no problem. But it seems suspicious at least...