[Android] Build Fail
See original GitHub issueRelease Type: Official Release/GitHub (please choose appropriate option) GitHub
Version: Version number and/or git branch master
Platform(s): Does the problem occur on Windows, Android…? Visual Studio 2022 Version 17.4.1 + Android NDK 20.1.5948944 on Windows (Android build).
Describe the bug Android.sln build fails.
Severity Code Description Project File Line Suppression State
Error MSB3073 The command ""C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe" -shared -o "E:\Stride Projects\stride\sources\core\Stride.Core\bin\Debug\net6.0-android\\armeabi-v7a\libcore.so" "E:\Stride Projects\stride\sources\core\Stride.Core\obj\Debug\net6.0-android\\CoreNative_armeabi-v7a.o" "E:\Stride Projects\stride\sources\core\Stride.Core\obj\Debug\net6.0-android\\lz4_armeabi-v7a.o" "E:\Stride Projects\stride\sources\core\Stride.Core\obj\Debug\net6.0-android\\lz4hc_armeabi-v7a.o" --sysroot="C:\Program Files (x86)\Android\android-sdk\ndk-bundle\platforms\android-9\arch-arm" "E:\Stride Projects\stride\sources\native\..\..\deps\\NativePath\Android\armeabi-v7a\libNativePath.a" -lc++abi -lm --sysroot="C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\sysroot" --target=armv7-linux-android16" exited with code 3. Stride.Core E:\Stride Projects\stride\sources\native\Stride.Native.targets 210
The path C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64 doesn’t exist in newer version of Visual Studio or Android NDK (probably), now it’s C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows. Also C:\Program Files (x86)\Android\android-sdk\ndk-bundle\platforms\android-9 should be replaced with C:\Program Files (x86)\Android\android-sdk\ndk-bundle\platforms\android-27 or any other the rest of the solution depends on.
Changing data inside Stride.Native.targets (line 190) from
[...]
<Target Name="CompileNativeClang_Android" Inputs="@(StrideNativeCFile);@(StrideNativeHFile)" Outputs="@(StrideNativeOutput)" Condition="'$(TargetFramework)' == '$(StrideFrameworkAndroid)' And $(DesignTimeBuild) != true And $(BuildingProject) != false" BeforeTargets="CoreCompile" DependsOnTargets="_StrideRegisterNativeOutputs">
<Error Text="The AndroidNdkDirectory environment variable is not set!" Condition="'$(AndroidNdkDirectory)' == ''" />
<PropertyGroup>
<StrideNativeAndroidClang>-lc++abi -lm --sysroot="$(AndroidNdkDirectory)\toolchains\llvm\prebuilt\windows-x86_64\sysroot"</StrideNativeAndroidClang>
<_StrideNativeAndroidNdkSourceProperties Condition="Exists('$(AndroidNdkDirectory)\source.properties')">$([System.IO.File]::ReadAllText('$(AndroidNdkDirectory)\source.properties'))</_StrideNativeAndroidNdkSourceProperties>
<StrideNativeAndroidNdkVersion>$([System.Text.RegularExpressions.Regex]::Match($(_StrideNativeAndroidNdkSourceProperties), `Pkg\.Revision = (.*)`).Groups[1].Value)</StrideNativeAndroidNdkVersion>
<StrideNativeAndroidNdkVersionMinimum>19.0</StrideNativeAndroidNdkVersionMinimum>
<!-- Android NDK version is equivalent to minSdkVersion; note: 64 bits exist only from platform version 21 -->
<StrideNativeAndroidPlatformVersion32>16</StrideNativeAndroidPlatformVersion32>
<StrideNativeAndroidPlatformVersion64>21</StrideNativeAndroidPlatformVersion64>
</PropertyGroup>
<Error Condition="'$(StrideNativeAndroidNdkVersion)' == ''" Text="Could not figure out Android NDK version from $(AndroidNdkDirectory). There should be a source.properties file with Pkg.Revision properly set." />
<Error Condition="$([System.Version]::Parse('$(StrideNativeAndroidNdkVersionMinimum)').CompareTo($([System.Version]::Parse('$(StrideNativeAndroidNdkVersion)')))) >= 0" Text="The Android NDK version is too old. Found: $(StrideNativeAndroidNdkVersion), Expected: $(StrideNativeAndroidNdkVersionMinimum), Location: $(AndroidNdkDirectory)" />
<MakeDir Directories="$(StrideNativeOutputPath)\armeabi-v7a"/>
<Exec Condition="'%(StrideNativeCFile.Extension)' != '.cpp'" Command=""$(MSBuildThisFileDirectory)..\..\deps\\LLVM\clang.exe" $(StrideNativeClang) -o "$(OutputObjectPath)\%(StrideNativeCFile.Filename)_armeabi-v7a.o" -c "%(StrideNativeCFile.FullPath)" -DANDROID -fPIC --target=armv7-linux-android$(StrideNativeAndroidPlatformVersion32)" />
<Exec Condition="'%(StrideNativeCFile.Extension)' == '.cpp'" Command=""$(MSBuildThisFileDirectory)..\..\deps\\LLVM\clang.exe" $(StrideNativeClangCPP) $(StrideNativeClang) -o "$(OutputObjectPath)\%(StrideNativeCFile.Filename)_armeabi-v7a.o" -c "%(StrideNativeCFile.FullPath)" -DANDROID -fPIC --target=armv7-linux-android$(StrideNativeAndroidPlatformVersion32)" />
<Exec Command=""$(AndroidNdkDirectory)\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe" $(StrideNativeToolingDebug) -shared -o "$(StrideNativeOutputPath)\armeabi-v7a\$(StrideNativeOutputName).so" @(StrideNativeCFile->'"$(OutputObjectPath)\%(Filename)_armeabi-v7a.o"', ' ') --sysroot="$(AndroidNdkDirectory)\platforms\android-9\arch-arm" @(StrideNativePathLibsAndroid->'"$(MSBuildThisFileDirectory)..\..\deps\\NativePath\Android\armeabi-v7a\%(Filename).a"', ' ') "$(MSBuildThisFileDirectory)..\..\deps\\NativePath\Android\armeabi-v7a\libNativePath.a" $(StrideNativeAndroidClang) --target=armv7-linux-android$(StrideNativeAndroidPlatformVersion32)" />
<MakeDir Directories="$(StrideNativeOutputPath)\arm64-v8a"/>
<Exec Condition="'%(StrideNativeCFile.Extension)' != '.cpp'" Command=""$(MSBuildThisFileDirectory)..\..\deps\\LLVM\clang.exe" $(StrideNativeClang) -o "$(OutputObjectPath)\%(StrideNativeCFile.Filename)_arm64-v8a.o" -c "%(StrideNativeCFile.FullPath)" -DANDROID -fPIC --target=aarch64-linux-android$(StrideNativeAndroidPlatformVersion64)" />
<Exec Condition="'%(StrideNativeCFile.Extension)' == '.cpp'" Command=""$(MSBuildThisFileDirectory)..\..\deps\\LLVM\clang.exe" $(StrideNativeClangCPP) $(StrideNativeClang) -o "$(OutputObjectPath)\%(StrideNativeCFile.Filename)_arm64-v8a.o" -c "%(StrideNativeCFile.FullPath)" -DANDROID -fPIC --target=aarch64-linux-android$(StrideNativeAndroidPlatformVersion64)" />
<Exec Command=""$(AndroidNdkDirectory)\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe" $(StrideNativeToolingDebug) -shared -o "$(StrideNativeOutputPath)\arm64-v8a\$(StrideNativeOutputName).so" @(StrideNativeCFile->'"$(OutputObjectPath)\%(Filename)_arm64-v8a.o"', ' ') --sysroot="$(AndroidNdkDirectory)\platforms\android-21\arch-arm64" @(StrideNativePathLibsAndroid->'"$(MSBuildThisFileDirectory)..\..\deps\\NativePath\Android\arm64-v8a\%(Filename).a"', ' ') "$(MSBuildThisFileDirectory)..\..\deps\\NativePath\Android\arm64-v8a\libNativePath.a" $(StrideNativeAndroidClang) --target=aarch64-linux-android$(StrideNativeAndroidPlatformVersion64)" />
<MakeDir Directories="$(StrideNativeOutputPath)\x86"/>
<Exec Condition="'%(StrideNativeCFile.Extension)' != '.cpp'" Command=""$(MSBuildThisFileDirectory)..\..\deps\\LLVM\clang.exe" $(StrideNativeClang) -o "$(OutputObjectPath)\%(StrideNativeCFile.Filename)_x86.o" -c "%(StrideNativeCFile.FullPath)" -DANDROID -fPIC --target=i386-linux-android$(StrideNativeAndroidPlatformVersion32)" />
<Exec Condition="'%(StrideNativeCFile.Extension)' == '.cpp'" Command=""$(MSBuildThisFileDirectory)..\..\deps\\LLVM\clang.exe" $(StrideNativeClangCPP) $(StrideNativeClang) -o "$(OutputObjectPath)\%(StrideNativeCFile.Filename)_x86.o" -c "%(StrideNativeCFile.FullPath)" -DANDROID -fPIC --target=i386-linux-android$(StrideNativeAndroidPlatformVersion32)" />
<Exec Command=""$(AndroidNdkDirectory)\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe" $(StrideNativeToolingDebug) -shared -o "$(StrideNativeOutputPath)\x86\$(StrideNativeOutputName).so" @(StrideNativeCFile->'"$(OutputObjectPath)\%(Filename)_x86.o"', ' ') --sysroot="$(AndroidNdkDirectory)\platforms\android-9\arch-x86" @(StrideNativePathLibsAndroid->'"$(MSBuildThisFileDirectory)..\..\deps\\NativePath\Android\x86\%(Filename).a"', ' ') "$(MSBuildThisFileDirectory)..\..\deps\\NativePath\Android\x86\libNativePath.a" $(StrideNativeAndroidClang) --target=i386-linux-android$(StrideNativeAndroidPlatformVersion32)" />
<MakeDir Directories="$(StrideNativeOutputPath)\x86_64"/>
<Exec Condition="'%(StrideNativeCFile.Extension)' != '.cpp'" Command=""$(MSBuildThisFileDirectory)..\..\deps\\LLVM\clang.exe" $(StrideNativeClang) -o "$(OutputObjectPath)\%(StrideNativeCFile.Filename)_x86_64.o" -c "%(StrideNativeCFile.FullPath)" -DANDROID -fPIC --target=x86_64-linux-android$(StrideNativeAndroidPlatformVersion64)" />
<Exec Condition="'%(StrideNativeCFile.Extension)' == '.cpp'" Command=""$(MSBuildThisFileDirectory)..\..\deps\\LLVM\clang.exe" $(StrideNativeClangCPP) $(StrideNativeClang) -o "$(OutputObjectPath)\%(StrideNativeCFile.Filename)_x86_64.o" -c "%(StrideNativeCFile.FullPath)" -DANDROID -fPIC --target=x86_64-linux-android$(StrideNativeAndroidPlatformVersion64)" />
<Exec Command=""$(AndroidNdkDirectory)\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe" $(StrideNativeToolingDebug) -shared -o "$(StrideNativeOutputPath)\x86_64\$(StrideNativeOutputName).so" @(StrideNativeCFile->'"$(OutputObjectPath)\%(Filename)_x86_64.o"', ' ') --sysroot="$(AndroidNdkDirectory)\platforms\android-21\arch-x86_64" @(StrideNativePathLibsAndroid->'"$(MSBuildThisFileDirectory)..\..\deps\\NativePath\Android\x86_64\%(Filename).a"', ' ') "$(MSBuildThisFileDirectory)..\..\deps\\NativePath\Android\x86_64\libNativePath.a" $(StrideNativeAndroidClang) --target=x86_64-linux-android$(StrideNativeAndroidPlatformVersion64)" />
<!-- Workaround: forcing C# rebuild so that timestamp are up to date (ideally we should have separate input/output groups for C# and Native) -->
<Delete Files="@(IntermediateAssembly)"/>
</Target>
[...]
to
[...]
<Target Name="CompileNativeClang_Android" Inputs="@(StrideNativeCFile);@(StrideNativeHFile)" Outputs="@(StrideNativeOutput)" Condition="'$(TargetFramework)' == '$(StrideFrameworkAndroid)' And $(DesignTimeBuild) != true And $(BuildingProject) != false" BeforeTargets="CoreCompile" DependsOnTargets="_StrideRegisterNativeOutputs">
<Error Text="The AndroidNdkDirectory environment variable is not set!" Condition="'$(AndroidNdkDirectory)' == ''" />
<PropertyGroup>
<StrideNativeAndroidClang>-lc++abi -lm --sysroot="$(AndroidNdkDirectory)\toolchains\llvm\prebuilt\windows\sysroot"</StrideNativeAndroidClang>
<_StrideNativeAndroidNdkSourceProperties Condition="Exists('$(AndroidNdkDirectory)\source.properties')">$([System.IO.File]::ReadAllText('$(AndroidNdkDirectory)\source.properties'))</_StrideNativeAndroidNdkSourceProperties>
<StrideNativeAndroidNdkVersion>$([System.Text.RegularExpressions.Regex]::Match($(_StrideNativeAndroidNdkSourceProperties), `Pkg\.Revision = (.*)`).Groups[1].Value)</StrideNativeAndroidNdkVersion>
<StrideNativeAndroidNdkVersionMinimum>19.0</StrideNativeAndroidNdkVersionMinimum>
<!-- Android NDK version is equivalent to minSdkVersion; note: 64 bits exist only from platform version 21 -->
<StrideNativeAndroidPlatformVersion32>16</StrideNativeAndroidPlatformVersion32>
<StrideNativeAndroidPlatformVersion64>21</StrideNativeAndroidPlatformVersion64>
</PropertyGroup>
<Error Condition="'$(StrideNativeAndroidNdkVersion)' == ''" Text="Could not figure out Android NDK version from $(AndroidNdkDirectory). There should be a source.properties file with Pkg.Revision properly set." />
<Error Condition="$([System.Version]::Parse('$(StrideNativeAndroidNdkVersionMinimum)').CompareTo($([System.Version]::Parse('$(StrideNativeAndroidNdkVersion)')))) >= 0" Text="The Android NDK version is too old. Found: $(StrideNativeAndroidNdkVersion), Expected: $(StrideNativeAndroidNdkVersionMinimum), Location: $(AndroidNdkDirectory)" />
<MakeDir Directories="$(StrideNativeOutputPath)\armeabi-v7a"/>
<Exec Condition="'%(StrideNativeCFile.Extension)' != '.cpp'" Command=""$(MSBuildThisFileDirectory)..\..\deps\\LLVM\clang.exe" $(StrideNativeClang) -o "$(OutputObjectPath)\%(StrideNativeCFile.Filename)_armeabi-v7a.o" -c "%(StrideNativeCFile.FullPath)" -DANDROID -fPIC --target=armv7-linux-android$(StrideNativeAndroidPlatformVersion32)" />
<Exec Condition="'%(StrideNativeCFile.Extension)' == '.cpp'" Command=""$(MSBuildThisFileDirectory)..\..\deps\\LLVM\clang.exe" $(StrideNativeClangCPP) $(StrideNativeClang) -o "$(OutputObjectPath)\%(StrideNativeCFile.Filename)_armeabi-v7a.o" -c "%(StrideNativeCFile.FullPath)" -DANDROID -fPIC --target=armv7-linux-android$(StrideNativeAndroidPlatformVersion32)" />
<Exec Command=""$(AndroidNdkDirectory)\toolchains\llvm\prebuilt\windows\bin\clang.exe" $(StrideNativeToolingDebug) -shared -o "$(StrideNativeOutputPath)\armeabi-v7a\$(StrideNativeOutputName).so" @(StrideNativeCFile->'"$(OutputObjectPath)\%(Filename)_armeabi-v7a.o"', ' ') --sysroot="$(AndroidNdkDirectory)\platforms\android-27\arch-arm" @(StrideNativePathLibsAndroid->'"$(MSBuildThisFileDirectory)..\..\deps\\NativePath\Android\armeabi-v7a\%(Filename).a"', ' ') "$(MSBuildThisFileDirectory)..\..\deps\\NativePath\Android\armeabi-v7a\libNativePath.a" $(StrideNativeAndroidClang) --target=armv7-linux-android$(StrideNativeAndroidPlatformVersion32)" />
<MakeDir Directories="$(StrideNativeOutputPath)\arm64-v8a"/>
<Exec Condition="'%(StrideNativeCFile.Extension)' != '.cpp'" Command=""$(MSBuildThisFileDirectory)..\..\deps\\LLVM\clang.exe" $(StrideNativeClang) -o "$(OutputObjectPath)\%(StrideNativeCFile.Filename)_arm64-v8a.o" -c "%(StrideNativeCFile.FullPath)" -DANDROID -fPIC --target=aarch64-linux-android$(StrideNativeAndroidPlatformVersion64)" />
<Exec Condition="'%(StrideNativeCFile.Extension)' == '.cpp'" Command=""$(MSBuildThisFileDirectory)..\..\deps\\LLVM\clang.exe" $(StrideNativeClangCPP) $(StrideNativeClang) -o "$(OutputObjectPath)\%(StrideNativeCFile.Filename)_arm64-v8a.o" -c "%(StrideNativeCFile.FullPath)" -DANDROID -fPIC --target=aarch64-linux-android$(StrideNativeAndroidPlatformVersion64)" />
<Exec Command=""$(AndroidNdkDirectory)\toolchains\llvm\prebuilt\windows\bin\clang.exe" $(StrideNativeToolingDebug) -shared -o "$(StrideNativeOutputPath)\arm64-v8a\$(StrideNativeOutputName).so" @(StrideNativeCFile->'"$(OutputObjectPath)\%(Filename)_arm64-v8a.o"', ' ') --sysroot="$(AndroidNdkDirectory)\platforms\android-27\arch-arm64" @(StrideNativePathLibsAndroid->'"$(MSBuildThisFileDirectory)..\..\deps\\NativePath\Android\arm64-v8a\%(Filename).a"', ' ') "$(MSBuildThisFileDirectory)..\..\deps\\NativePath\Android\arm64-v8a\libNativePath.a" $(StrideNativeAndroidClang) --target=aarch64-linux-android$(StrideNativeAndroidPlatformVersion64)" />
<MakeDir Directories="$(StrideNativeOutputPath)\x86"/>
<Exec Condition="'%(StrideNativeCFile.Extension)' != '.cpp'" Command=""$(MSBuildThisFileDirectory)..\..\deps\\LLVM\clang.exe" $(StrideNativeClang) -o "$(OutputObjectPath)\%(StrideNativeCFile.Filename)_x86.o" -c "%(StrideNativeCFile.FullPath)" -DANDROID -fPIC --target=i386-linux-android$(StrideNativeAndroidPlatformVersion32)" />
<Exec Condition="'%(StrideNativeCFile.Extension)' == '.cpp'" Command=""$(MSBuildThisFileDirectory)..\..\deps\\LLVM\clang.exe" $(StrideNativeClangCPP) $(StrideNativeClang) -o "$(OutputObjectPath)\%(StrideNativeCFile.Filename)_x86.o" -c "%(StrideNativeCFile.FullPath)" -DANDROID -fPIC --target=i386-linux-android$(StrideNativeAndroidPlatformVersion32)" />
<Exec Command=""$(AndroidNdkDirectory)\toolchains\llvm\prebuilt\windows\bin\clang.exe" $(StrideNativeToolingDebug) -shared -o "$(StrideNativeOutputPath)\x86\$(StrideNativeOutputName).so" @(StrideNativeCFile->'"$(OutputObjectPath)\%(Filename)_x86.o"', ' ') --sysroot="$(AndroidNdkDirectory)\platforms\android-27\arch-x86" @(StrideNativePathLibsAndroid->'"$(MSBuildThisFileDirectory)..\..\deps\\NativePath\Android\x86\%(Filename).a"', ' ') "$(MSBuildThisFileDirectory)..\..\deps\\NativePath\Android\x86\libNativePath.a" $(StrideNativeAndroidClang) --target=i386-linux-android$(StrideNativeAndroidPlatformVersion32)" />
<MakeDir Directories="$(StrideNativeOutputPath)\x86_64"/>
<Exec Condition="'%(StrideNativeCFile.Extension)' != '.cpp'" Command=""$(MSBuildThisFileDirectory)..\..\deps\\LLVM\clang.exe" $(StrideNativeClang) -o "$(OutputObjectPath)\%(StrideNativeCFile.Filename)_x86_64.o" -c "%(StrideNativeCFile.FullPath)" -DANDROID -fPIC --target=x86_64-linux-android$(StrideNativeAndroidPlatformVersion64)" />
<Exec Condition="'%(StrideNativeCFile.Extension)' == '.cpp'" Command=""$(MSBuildThisFileDirectory)..\..\deps\\LLVM\clang.exe" $(StrideNativeClangCPP) $(StrideNativeClang) -o "$(OutputObjectPath)\%(StrideNativeCFile.Filename)_x86_64.o" -c "%(StrideNativeCFile.FullPath)" -DANDROID -fPIC --target=x86_64-linux-android$(StrideNativeAndroidPlatformVersion64)" />
<Exec Command=""$(AndroidNdkDirectory)\toolchains\llvm\prebuilt\windows\bin\clang.exe" $(StrideNativeToolingDebug) -shared -o "$(StrideNativeOutputPath)\x86_64\$(StrideNativeOutputName).so" @(StrideNativeCFile->'"$(OutputObjectPath)\%(Filename)_x86_64.o"', ' ') --sysroot="$(AndroidNdkDirectory)\platforms\android-27\arch-x86_64" @(StrideNativePathLibsAndroid->'"$(MSBuildThisFileDirectory)..\..\deps\\NativePath\Android\x86_64\%(Filename).a"', ' ') "$(MSBuildThisFileDirectory)..\..\deps\\NativePath\Android\x86_64\libNativePath.a" $(StrideNativeAndroidClang) --target=x86_64-linux-android$(StrideNativeAndroidPlatformVersion64)" />
<!-- Workaround: forcing C# rebuild so that timestamp are up to date (ideally we should have separate input/output groups for C# and Native) -->
<Delete Files="@(IntermediateAssembly)"/>
</Target>
[...]
fixes the problem, but i’m not sure about previous/other versions of Visual Studio and/or AndroidNDK.
To Reproduce Steps to reproduce the behavior:
- Open Android.sln inside Visual Studio 2022 Version 17.4.1 with Android NDK 20.1.5948944 installed.
- Try to build project
Expected behavior Build project.
Issue Analytics
- State:
- Created 10 months ago
- Comments:9 (3 by maintainers)
Top GitHub Comments
@tebjan @ykafia
No. The OP’s initial problem seems to be that clang.exe does not exist in folder “windows-x86_64” We ran into the same error building Stride.Android
File: Stride.Native.targets Line 210,5 <Exec Command=""$(AndroidNdkDirectory)\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe"
Error
Visual Studio 2022 installs Clang.exe in folder:
“C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows\bin”
My issue was that when creating new Android game project there were problems with references (my first comment), the issues with paths didn’t cause me as much trouble as with the paths and I didn’t know why it’s happening. Gonna check new build when I’ll have some free time.