Android Vulkan — NDK Update

“person holding silver adjustable wrench” by rawpixel on Unsplash

Will update the content if new versions come out.

NDK r18

I update NDK version to r18 for a new feature VK_KHR_multiview. And some changes are applied to layerlib/CMakeLists.txt due to updates of Vulkan layers and STL backend for Android Studio.

Version

I found NDK r17 is pretty much the same with that in r18 in Vulkan layer files so I group command blocks with r17 as a baseline. NDK version is referenced by the variable ${ANDROID_NDK_REVISION}.

Definition

I don’t want any duplicated compiling flags so I back up the original CPP flags of each CMakeLists.txt to CMAKE_CXX_clone which is used to restore the CPP flags at the end. Then I separate macro symbols from CMAKE_CXX_FLAGS in order for definitions to be in effect after CPP flags are restored.

Vulkan Layer

  • VK_LAYER_LUNARG_swapchain
The remaining functionality in the VK_LAYER_LUNARG_swapchain layer has been migrated into the VK_LAYER_LUNARG_core_validation layer

https://vulkan.lunarg.com/doc/sdk/1.0.51.0/windows/release_notes-1.0.html

  • VK_LAYER_LUNARG_image
    Disappeared after Vulkan 1.0.39.1, not even mentioned in changelog.

Layers Source Files

Source files for building layer libraries are different between versions, check layerlib/CMakeLists.txt in detail.

STL

LLVM’s libc++ is the C++ standard library that has been used by the Android OS since Lollipop, and as of NDK r18 is the only STL available in the NDK.

Note

We might get a message like saying

WARNING: ABIs [armeabi-v7a,armeabi] set by ‘android.injected.build.abi’ gradle flag contained ‘ARMEABI’ not targeted by this project

while building the project. It happened when I upgraded NDK version to r18 and I found no solutions about this problem(it’s just a warning, our app still works).

And we might need to delete cmake folder in \.externalNativeBuild in order to avoid the error stating that linker cannot find libc++.so. The name of STL libraries began to have version postfix like libc++.so.21, libc++.so.22, etc, from r18, which indicates Android platform version.