I just got this error after linking JUCE 5.4.5 as a static library to a non-JUCE Android app. Does anyone have tips for dealing with this issue?
My full error message was:
JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception java.lang.ClassNotFoundException: Didn't find class "com.roli.juce.JuceSharingContentProvider" on path: DexPathList[[zip file "/data/app/com.oculus.sdk.vrinput-2/base.apk"],nativeLibraryDirectories=[/data/app/com.oculus.sdk.vrinput-2/lib/arm64, /data/app/com.oculus.sdk.vrinput-2/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
Some context of how I got here:
I’m making an Oculus VR app for Android and I want to access some JUCE code, particularly OSC Messaging functionality. My project specifically needs a static library as opposed to a dynamic library due to the default configuration of the Oculus SDK. I want to link a static
.a JUCE library for my applications’ native C++ code to use.
When building the default JUCE Static library project from the Projucer in Android Studio, it was difficult for me to find the static library (
.a) file that was produced. In the
Builds/Android/lib/build/outputs folder, the only thing that seemed to be built was an
.aar file which I think is an Android static library, but I was hoping to get a regular static library
.a file. I then checked
Builds/Android/lib/build/intermediates/cmake/... and found the various
.a files corresponding to the static libraries for different build configurations. I also had to find the static library which JUCE depends on,
libcpufeatures.a in the folder Builds/Android/lib/.cxx/cmake/…`. (It feels awkward/wrong that I am accessing the static libraries in this way, so if someone knows a more correct way, I would love to hear.)
For my VR app, I manually linked the two static libraries successfully, but I ended up with the runtime error listed above.
I would appreciate any tips here as I am new to Android and best library linking practices.