Android shared-library for Unity

I’m trying to create an android shared library for use in Unity3D.

I have it building in Android Studio with the NDK and I can get Unity to use it deploying to an emulator and device

but I’m not having any success at getting JUCE to run.

i’m not clear how I should initialiseJUCE, or interact with the deviceManager etc

#include "jni.h"
#include "shalib.h" // just has #include "../JuceLibraryCode/JuceHeader.h"

extern "C" JNIEXPORT const char* JNICALL
        JNIEnv* env,
        jobject /* this */) {
        //Thread::initialiseJUCE(env, whatgoeshere?); // this crashes the app

        AudioFormatManager formatManager;
        AudioDeviceManager deviceManager;

        //deviceManager.initialiseWithDefaultDevices(0, 2);// this crashes the app

   // returns right at the end if the app is still alive!!
   std::string hello = "This *is* the string you are looking for";
    return hello.c_str();

I’ve been hacking around with this and I think I’m getting closer.

i’m building an AAR, which is hosted in unity3D and I can call both java (where, i think, i’m getting JUCE to initialise) and native classes.(via Java->JNI & directly)

i’m able to set-up a device manager and get back the Sample Rate

        AudioDeviceManager deviceManager;
        deviceManager.initialiseWithDefaultDevices(0, 2);
        auto* device = deviceManager.getCurrentAudioDevice();
        i = device->getCurrentSampleRate(); // i'm returning tis via another method


returning i back to Unity3D gives 48000

Does this confirm that JUCE is initialised?

deviceManager.playTestSound(); does not cause any kind of exception, but does not play the tone. Any suggestions?

got the audio to work now.

need to add Thread::sleep(5000);