How to import a JUCE static library on an Android project?

Thanks to the Projucer, I created this very basic project, just to understand how to generate a static library for Android and how to import it on an Android project:

I managed to generate the library and locate the .a files for each configuration (arm64-v8a, armeabi-v7a, x86, x86_64).

Now I’m trying to import it on an Android project, and here is what I did:

  • in src/main/cpp/jucedemo/lib , I added the 4 directories (arm64-v8a , armeabi-v7a , x86 , x86_64), with the different versions of my libJuceDemo.a in each directory

  • I also added a include directory with JuceHeader.h, JuceTest.h and AppConfig.h in it, as you can see here:

  • I added the following in my CMakeLists.txt file:

Then I tried to call the code of the library from my JNI (C++) code of my Android app:

  • In another C++ file of my Android project (native-lib.cpp), I import the JuceTest.h header like this:
#include "jucedemo/lib/include/JuceTest.h
  • In that same file (native-lib.cpp), in a function, I try to use the JuceTest class:
jucetest::JuceTest juceTest;

Now when I try to compile and run my Android app, I get these errors:

error: undefined reference to 'jucetest::JuceTest::JuceTest()'
error: undefined reference to 'jucetest::JuceTest::getTexte()'
error: undefined reference to 'jucetest::JuceTest::~JuceTest()'

I believe there is something wrong with the content of the JuceTest.h header file in the include directory, but I can’t find what it is.

Thanks for your help.

OK, so here is what I forgot to add in my CMakeLists.txt file:

    # add this:

    # ...

And now it works!