Hello,
At Ubisoft, we have a custom CMake that we maintain with patches originally based on VCMDDAndroid to support the Visual Studio generator with Android. We recently faced issues when updating the NDK as the VCTargets file provided with Visual Studio 2019 only
support the NDK up to version r16. We did some manual changes, but were hoping to see these changes incorporated directly in Visual Studio in a future update.
In C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Application Type\Android\3.0\
First, we patched Android.STL.props to remove android_support for newer NDKs.
--- Android.STL.props.backup 2019-08-06 13:40:36.518362100 +0000
+++ Android.STL.props.good 2019-09-23 08:35:16.162782600 +0000
@@ -76,13 +76,21 @@
</PropertyGroup>
<!-- Starting NDK16, use this order of include paths to support unified headers and the removal of old headers -->
- <PropertyGroup Condition="'$(NDKVersion)' != '' and '$(NDKVersion)' >= '16.0' and ('$(UseOfStl)' == 'c++_static' or '$(UseOfStl)' == 'c++_shared')">
+ <PropertyGroup Condition="'$(NDKVersion)' != '' and '$(NDKVersion)' >= '16.0' and '$(NDKVersion)' < '17.0' and ('$(UseOfStl)' == 'c++_static' or '$(UseOfStl)' == 'c++_shared')">
<StlIncludeDirectories>$(VS_NdkRoot)\sources\cxx-stl\llvm-libc++\include;$(VS_NdkRoot)\sources\cxx-stl\llvm-libc++abi\include</StlIncludeDirectories>
<StlAdditionalDependencies Condition="'$(StlIsStaticLibrary)' == 'true'">$(StlLibraryPath)\libandroid_support.a;$(StlAdditionalDependencies);$(StlLibraryPath)\libc++abi.a</StlAdditionalDependencies>
<!-- This convert StlLibraryName to an array -->
<StlLibraryName>android_support;$(StlLibraryName);c++abi;</StlLibraryName>
</PropertyGroup>
+ <!-- Starting NDK17, use this order of include paths to support unified headers and the removal of old headers -->
+ <PropertyGroup Condition="'$(NDKVersion)' != '' and '$(NDKVersion)' >= '17.0' and ('$(UseOfStl)' == 'c++_static' or '$(UseOfStl)' == 'c++_shared')">
+ <StlIncludeDirectories>$(VS_NdkRoot)\sources\cxx-stl\llvm-libc++\include;$(VS_NdkRoot)\sources\cxx-stl\llvm-libc++abi\include</StlIncludeDirectories>
+ <StlAdditionalDependencies Condition="'$(StlIsStaticLibrary)' == 'true'">$(StlAdditionalDependencies);$(StlLibraryPath)\libc++abi.a</StlAdditionalDependencies>
+ <!-- This convert StlLibraryName to an array -->
+ <StlLibraryName>$(StlLibraryName);c++abi;</StlLibraryName>
+ </PropertyGroup>
+
<ItemDefinitionGroup>
<ClCompile Condition="'$(UseOfStl)' == 'c++_static' or '$(UseOfStl)' == 'c++_shared'">
<CppLanguageStandard>c++11</CppLanguageStandard>
Second, we patched the NDK version file, but the actual fix should be done in Android.NDK.props. This file load the LLVM version with the following code:
<LLVMVersion Condition="Exists('$(LLVMToolchainPrebuiltRoot)\AndroidVersion.txt')">$([System.IO.File]::ReadAllText('$(LLVMToolchainPrebuiltRoot)\AndroidVersion.txt').Trim())</LLVMVersion></PropertyGroup>
Recent NDKs however also have the commit hash in the file:
8.0.2
based on r339409
The code need to be updated to only extract 8.0.2 from this file, and discard the remaining.