No, this is already done for the JUCE classes. The README in juce_core is just a guide on how to re-build and debug them if needed.
@ed95 Thank you so much for the help Ed, my app now runs successfully! It seems moving to the latest JUCE development branch and Projucer has fixed the error for me. Thank you again!
I did get a build warning for JUCE included below, but this may be a known warning.
If this is helpful for anyone who later views this thread, Iâve included the steps I took to get a JUCE static library working on Android:
Building JUCE as a Static Library for Android
- Download latest JUCE source repository from GitHub and switch to develop branch.
- Build Projucer app in release build mode (following instructions in the JUCE
README.md
). - Create a Static Library project type in the Projucer and set module path to link the the local JUCE repository on develop.
- Set an exporter for Android and configure various settings you may need (MIN_SDK_VERSION, TARGET_SDK_VERSION).
- Set the Projucer project to use C++17.
- Save the Projucer project.
- Click the exporter button in Projucer to open the project in Android Studio.
- Press the Sync Project with Gradle button in Android Studio.
- Build the project in Debug mode.
- Build the project in Release mode.
In all builds I received the following warnings. In the past, I have received these warnings and I sometimes remove the mode bits parameter in the call to open()
to get rid of these warnings. But in this case, I did not modify anything.
In file included from /Users/timarterbury/Documents/SDKs/ovr_sdk_mobile_1.29.0-a3/3rdParty/juce/juce_static_lib/JuceLibraryCode/include_juce_core.cpp:9:
In file included from ../../../../../../../../juce/modules/juce_core/juce_core.cpp:189:
../../../../../../../../juce/modules/juce_core/native/juce_posix_SharedCode.h:418:68: warning: 'open' has superfluous mode bits; missing O_CREAT? [-Wuser-defined-warnings]
auto f = open (file.getFullPathName().toUTF8(), O_RDONLY, 00644);
^
/Users/timarterbury/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/bits/fortify/fcntl.h:76:9: note: from 'diagnose_if' attribute on 'open':
__clang_warning_if(!__open_modes_useful(flags) && modes,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/timarterbury/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/sys/cdefs.h:135:54: note: expanded from macro '__clang_warning_if'
#define __clang_warning_if(cond, msg) __attribute__((diagnose_if(cond, msg, "warning")))
^ ~~~~
In file included from /Users/timarterbury/Documents/SDKs/ovr_sdk_mobile_1.29.0-a3/3rdParty/juce/juce_static_lib/JuceLibraryCode/include_juce_core.cpp:9:
In file included from ../../../../../../../../juce/modules/juce_core/juce_core.cpp:189:
../../../../../../../../juce/modules/juce_core/native/juce_posix_SharedCode.h:455:70: warning: 'open' has superfluous mode bits; missing O_CREAT? [-Wuser-defined-warnings]
auto f = open (file.getFullPathName().toUTF8(), O_RDWR, 00644);
^
/Users/timarterbury/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/bits/fortify/fcntl.h:76:9: note: from 'diagnose_if' attribute on 'open':
__clang_warning_if(!__open_modes_useful(flags) && modes,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/timarterbury/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/sys/cdefs.h:135:54: note: expanded from macro '__clang_warning_if'
#define __clang_warning_if(cond, msg) __attribute__((diagnose_if(cond, msg, "warning")))
^ ~~~~
2 warnings generated.
- Regardless of these warnings, all builds succeeded for me.
- To find the static library files produced from the build, I went to a subdirectory in my
juce_static_lib
JUCE project folder:Builds/Android/lib/build/intermediates/cmake/...
and traversed to the appropriate build configuration folder to find thelibjuce_static_lib.a
file. I wouldâve expected to see these inBuilds/Android/lib/build/outputs/...
but I only see.aar
files and logs, but this may be my own misunderstanding. The.aar
files are quite tiny 2KB, while the static library.a
files are around 100MB.
After this successful build I then linked my Android VR app to the following libraries:
-
JUCE Static Library:
Builds/Android/lib/build/intermediates/cmake/$(JUCE_CMAKE_BUILD_VARIANT)/obj/$(TARGET_ARCH_ABI)/libjuce_static_lib.a
-
Android CPU Features Static Library:
Builds/Android/lib/.cxx/cmake/$(JUCE_CMAKE_BUILD_VARIANT)/$(TARGET_ARCH_ABI)/libcpufeatures.a
Quick followup question:
If I used the Projucer to build a static library of JUCE, and I linked that library to an Android project which is not using JUCE to manage the full app functionality via the JuceApp
Java class, do I manually need to call Thread::initialiseJUCE()
(or the Java alternative) on app startup? Do I need to call this function if I plan to use any of the JUCE event system?
My app seemed to run fine without doing this, as it only uses some OSC message sending functionality. I was able to successfully send an OSC message on a Network.
Thanks again for the help.
Yes you would. You can use the handy ScopedJuceInitialiser_GUI
class for RAII startup and shutdown of JUCE events etc in your main app class.
This wonât call Thread::initailiseJUCE()
, it just sets up the message loop. If you arenât using the autogenerated com.roli.juce.JuceApp
Java class then youâll need to call Thread::initialiseJUCE()
somewhere in your app in addition to using the scoped initialiser. This post contains some useful information on what needs to be done.
Must I call Thread::initailiseJUCE()
even if I do not plan to use JUCE GUI or JUCE Event related functionality?
I have the same âWarningâ issue since I have updated the ndk (I think itâs related)
Any news on that subject ?
Regards
Edit: It has been fixed on the develop branch (#e65ac0b)