Can't run Juce code on Android (assertion failure in juce_android_SystemStats.cpp and SIGSEGV)


I got a c++ project using Qt that I can run on Android.

When I put some Juce code in it (like some lines in the main), the Android app craches with this trace:

12-07 22:38:03.270 7602-7602/org.qtproject.example.myproject W/ResourceType: Failure getting entry for 0x01080ac1 (t=7 e=2753) (error -75)
12-07 22:38:03.300 7602-7602/org.qtproject.example.myproject D/PhoneWindow: *FMB* installDecor mIsFloating : false
12-07 22:38:03.300 7602-7602/org.qtproject.example.myproject D/PhoneWindow: *FMB* installDecor flags : 8454400
12-07 22:38:03.340 7602-7602/org.qtproject.example.myproject I/Qt: qt start
12-07 22:38:03.450 7602-7620/org.qtproject.example.myproject D/OpenGLRenderer: Render dirty regions requested: true
12-07 22:38:03.455 7602-7602/org.qtproject.example.myproject D/Atlas: Validating map...
12-07 22:38:03.475 7602-7602/org.qtproject.example.myproject D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
12-07 22:38:03.475 7602-7602/org.qtproject.example.myproject D/PhoneWindow: *FMB* isFloatingMenuEnabled return false
12-07 22:38:03.510 7602-7620/org.qtproject.example.myproject I/OpenGLRenderer: Initialized EGL, version 1.4
12-07 22:38:03.520 7602-7620/org.qtproject.example.myproject I/OpenGLRenderer: HWUI protection enabled for context ,  &this =0xaf722088 ,&mEglDisplay = 1 , &mEglConfig = -1351355468
12-07 22:38:03.540 7602-7620/org.qtproject.example.myproject D/OpenGLRenderer: Get maximum texture size. GL_MAX_TEXTURE_SIZE is 8192
12-07 22:38:03.540 7602-7620/org.qtproject.example.myproject D/OpenGLRenderer: Enabling debug mode 0
12-07 22:38:03.565 7602-7629/org.qtproject.example.myproject I/JUCE: JUCE Assertion failure in juce_android_SystemStats.cpp:106
12-07 22:38:03.570 7602-7629/org.qtproject.example.myproject A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 7629 (xample.myproject)
12-07 22:38:03.575 7602-7620/org.qtproject.example.myproject E/libEGL: error opening cache file /data/data/org.qtproject.example.myproject/cache/ Permission denied (13)
12-07 22:38:03.580 7602-7602/org.qtproject.example.myproject I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@2cdaf801 time:244702

The juce_android_SystemStats.cpp:106 is the getEnv function:

JNIEnv* getEnv() noexcept
    JNIEnv* env = androidJNIEnv.get();
    jassert (env != nullptr);

    return env;

What could be wrong ?


Thanks !

If it's not an introjucer-generated project that you're probably missing the java activity class that the juce code needs for some of its OS functionality. That'd be why it can't find that stuff.

Yes, it is not an Introjucer-generated project but a project using the Qt build toolchain (qmake + qtdeployandroid).

Qt's Android build toolchain ( produces all the Android required stuff including a java activity class which does not include Juce special code.

What Juce special code should I put to get the things working ?

What are the Juce requirements in terms of Android compliance ?

In other words, how can I make Juce working with Qt using the Qt build toolchain ?

We provide the introjucer to generate everything a juce project needs, so if you're going off-piste with a completely different build system then you'll need to figure that out yourself, I'm afraid. I don't have a clue about how Qt builds are structured, and can't help with that.

The place to look would be to create a simple project with the introjucer (or just look at the juce demo one) and look at the java activity file that it generates. That's what we use to bootstrap juce, and juce will expect to be able to find all the methods and classes that it provides to interface with the OS.