Android 11 – System.loadLibrary for native C++ library takes 60+ seconds, works perfectly fast on Android 10 and below

In our game application for Android which is based on the game engine cocos2d-x, with most of the code being written in C++, we have a very strange and critical issue since Android 11:

When the native library gets loaded in onLoadNativeLibraries it now suddenly takes 60+ seconds. Before Android 11, it all worked fine and it loaded in 0.2-3 seconds. Now when you start the game, you have a 60+ seconds gray screen.

We already figured out that JNI_OnLoad gets called directly after the 60 second stall is over.

Here’s the code of the onLoadNativeLibraries

protected void onLoadNativeLibraries()
        ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);
        Bundle bundle = ai.metaData;
        String libName = bundle.getString("");
        System.loadLibrary(libName); // line of 60 seconds stall
    catch (Exception e)

We already tried time profiling, but without any success. It just hows that it’s spending a lot of time on that function. Also pausing via the debugging doesn’t lead to any further clues. The native debugger doesn’t show anything on the C++ side of the code.

Does anybody have any idea why this is happening or what we could try to figure it out? Any help would be highly appreciated 🙂

Source: Windows Questions C++