Build juce shared library for Android, stuck


Dear Juce Experts,

I'm trying to compile Juce library for Android, so I can link to something like and my C++ code can utilize awesome classes like AudioSampleBuffer etc.  So here's what I did:

1. Projucer an Android gui application, compiled it with Android Studio successfully. 

2. in path_to_my_folder\AndroidStudio\app\build\intermediates\binaries\debug\armeabi-v7a\lib\armeabi-v7a, I found

3. Write an to link to this, while including JuceHeader.h in the correct folder 

4. Then when I'm trying to link to it this way, I got:

"/../../JuceLibraryCode/modules/juce_opengl/../../../../JUCE/modules/juce_opengl/juce_opengl.h:59:20: fatal error: GL/gl.h: No such file or directory  #include <GL/gl.h> "

Apparently in this juce_opengl.h, it think JUCE_WINDOWS is active and not JUCE_ANDROID flag. 


At this point I'm banging my head and stuck, CouldJu help? Am I doing this whole thing right, or did I miss the correct way to set some flag to get around this?

Thanks in advance.


Another option might be to import your existing C++ code into your JUCE project (maybe wrap it in a JUCE module) and compile it for Android... that way you save messing around with static libraries which in my experience can be a bit of a pain.


It seems like you are not defining JUCE_ANDROID. Try setting this from the compiler command line.


Building C++ libraries for Android, whether static or dynamic, is currently not supported.

The reason is that a lot of JUCE functionality on Android relies on our JUCE AppActivity class written in Java. But if you are building a library, you don't have that activity class.

I'll put an assert or error message into the Introjucer making clear that this is not supposed to work.

Building stand-alone Android JUCE library (Early 2018)

Is this still true?


Well it’s semi-true. Timur is right that a lot of JUCE code needs JUCE’s AppActivity to be the app activity of your android app. Basically (almost) any code that needs to call into java will likely fail when linked as a shared/static library.

Off the top of my head you won’t be able to use the following:

  • juce_gui_basics/juce_gui_extra: everything
  • juce_graphics: all font and text stuff
  • juce_events: anything to do with the message loop
  • juce_core: anything that requires loading a URL, realtime audio threading priorities, some stuff in SystemStats (a lot of stuff in JUCE indirectly uses SystemStats :frowning:)
  • juce_audio_devices: everything
  • juce_opengl: everything

I think most of the stuff in juce_audio_basics, juce_audio_processors and juce_dsp should be fine.