Steps to reproduce:
1. Open the attached user's project "AndroidNdkApiLevel26.zip"
2. Make sure that Android is selected as the platform
3. Make sure that IL2CPP scripting backend and minimum API level is 26 or higher are selected
4. Build the Android Player
5. Observe the error in the Console
Expected results: build doesn't fail
Actual results: android IL2CPP build fails when the project contains native plugins that use NDK APIs that are available in the project's minimum API level but not available in API 22
Reproducible on: 2020.3.41f1, 2021.3.15f1, 2021.3.27f1, 2022.1.24f1, 2022.2.a10
Not reproducible on: 2022.2.a11, 2022.2.0f1, 2022.3.4f1, 2023.1.0a23, 2023.1.3f1, 2023.2.0a19
Notes:
-There are additional IL2CPP linker flags set in ProjectSettings.asset, do not remove them. They are needed to link against the NDK libraries
-When building a Unity project for Android with IL2CPP as the scripting backend, the API level passed to the C compiler and linker is fixed at 22, even if the project's minimum API level is higher. This causes the build to fail when the project contains native plugins that use NDK APIs that are available in the project's minimum API level but not available in API 22
-Error that gets outputted:
Building Library\Bee\artifacts\Android\d8kzr\v1kj_tivePlugin.o failed with output:
D:\Cases\AndroidNdkApiLevel26\AndroidNdkApiLevel26\Library\Bee\artifacts\Android\il2cppOutput\cpp\NativePlugin.cpp(5,5): error: use of undeclared identifier 'AImageReader_newWithUsage'
AImageReader_newWithUsage(
^