使用托管 tfs 构建服务器构建 Xamarin.Android 时缺少 Android NDK 工具链目录 '\toolchains'
Missing Android NDK toolchains directory '\toolchains' when building Xamarin.Android with hosted tfs build server
我正在尝试设置一个 TFS Build agent
以在每次签入时自动构建我的 Xamarin.Android
项目。
我已按照此处概述的步骤进行操作:https://msdn.microsoft.com/library/vs/alm/build/apps/xamarin 设置托管构建代理。
TFS 构建模板也有一个 Xamarin.Android
模板,您会认为这意味着它们已准备就绪。这也得到了上述 link 的支持,其中指出您可以在托管池
上构建 Xamarin.Android
解决方案
但是我在构建项目时不断收到以下错误:
Missing Android NDK toolchains directory '\toolchains'. Please install
the Android NDK
我在 Xamarin https://developer.xamarin.com/guides/cross-platform/ci/configuring_tfs/tfs-and-xa/ 找到了一个 link,它说我需要登录构建机器并将 Android NDK 复制并粘贴到我的远程机器上。
但显然使用托管池我无法登录计算机。
我的设置中是否遗漏了什么?
Xamarin论坛上也有同样的问题,解决方法如下:
Fixed: As an update if anyone else having this problem when building
Release (that the NDK \toolchains is missing) it appears that mkbundle
is broken.
The root cause is that "MakeBundleNativeCodeExternal" is true for
release and false for Debug. Although this appears as a licensing
issue, my build agent has an Enterprise licence installed.
Disabling "MakeBundleNativeCodeExternal" in Release build by editing
the Android project in notepad, seach for 'BundleAssemblies' - and
change the 'True' under Release configuration section to ' False'
save, build Release, works.
参考这个link了解详情:Missing Android NDK toolchains directory
解决此问题的分步指南。
如果可以,我建议您使用 Visual Studio 2015 Update 2 和 Xamarin 设置您自己的构建主机,并确保 this link. After doing so you can use this Xamarin link。 1. 你的 java SDK 和 NDK 在本地(非用户特定区域,如果你使用 visual studio 安装它们应该是)并且已经添加了环境变量(来自 Xamarin link):
Adjusting Environment Variables During the automated build process
Xamarin.Android will require access to the Android SDK and NDK at the
paths that were adjusted above. This is best done by setting ot
adjusting several server wide environment variables:
If not already, log in to the TFS machine as Administrator. Open
Control Panel, type Environment in the search box, select Edit the
system environment variables, and then click the Environment
Variables... button to bring up the following dialog:
Under System variables select ANDROID_HOME and click Edit…, or if
ANDROID_HOME doesn’t exist, click New… to create it:
Set the value to c:\android-sdk (or wherever you moved the SDK) and
click OK. Under System variables select ANDROID_NDK_PATH and click
Edit… (or New… if necessary):
Set the value to c:\android-ndk\android-ndk-r8d (or wherever you moved
the NDK) and click OK. Note that you do need the second folder name in
this value. Select the Path variable, click Edit… button, and append
;c:\android-sdk (or whatever folder you used) to the end of the path
and click OK. Don’t forget to include the semi-colon (;) separator
between this and previous entries.
Verify the changes by opening a command prompt, entering Set, and
examining the variables. The Team Foundation Server should now be able
to build Android apps in a team project.
在此之后,您必须在 project.Android.csproj 文件中将以下属性设置为 False
。
在记事本中打开文件,
转到发布配置部分
并将以下设置为 false:
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
<BundleAssemblies>False</BundleAssemblies>
您的项目现在将构建在托管池上!
虽然我认为这隐藏了真正的问题,因为将这些设置为 true 将在您的本地构建代理上构建。
我认为 Microsoft 托管池缺少 Android NDK 环境变量,因为它没有出现在 TFS 的功能中
最初的问题是关于在 Azure DevOps 托管代理上构建 Xamarin Android 应用程序并出现错误,因为找不到 Android NDK。
是的,如果您禁用 EmbedAssembliesIntoApk
或 BundleAssemblies
等选项,构建将正常运行,但这不是真正的解决方案,尤其是当您需要启用这些选项时。
由于在托管代理上构建时找不到 Android NDK 路径,因此解决方案是手动设置 Android NDK 路径。
在构建任务的 MSBuild 选项中,提供以下附加参数:
- VS2015 托管代理:
/p:AndroidNdkDirectory="C:\java\androidsdk\android-ndk-r13b"
- VS2017 托管代理:
/p:AndroidNdkDirectory="$(latestAndroidNDKPath)"
如果您想了解有关此问题的更多信息,我写了一篇文章,将为您提供更多详细信息:
如何在 VS2017 托管代理上检索最新的 Android NDK:
$ndk_root = "C:\Microsoft\AndroidNDK64\"
if(Test-Path $ndk_root) {
$androidNDKs = Get-ChildItem -Path $ndk_root | Sort-Object -Property Name -Descending | Select-Object -First 1
$latestAndroidNDK = $androidNDKs.FullName;
Write-Host "##vso[task.setvariable variable=latestAndroidNDKPath]$latestAndroidNDK"
} else {
Write-Host "NDK is not installed at path $ndk_root"
exit 1
}
Write-Host Variable '$(latestAndroidNDKPath)' is $latestAndroidNDK
我正在尝试设置一个 TFS Build agent
以在每次签入时自动构建我的 Xamarin.Android
项目。
我已按照此处概述的步骤进行操作:https://msdn.microsoft.com/library/vs/alm/build/apps/xamarin 设置托管构建代理。
TFS 构建模板也有一个 Xamarin.Android
模板,您会认为这意味着它们已准备就绪。这也得到了上述 link 的支持,其中指出您可以在托管池
Xamarin.Android
解决方案
但是我在构建项目时不断收到以下错误:
Missing Android NDK toolchains directory '\toolchains'. Please install the Android NDK
我在 Xamarin https://developer.xamarin.com/guides/cross-platform/ci/configuring_tfs/tfs-and-xa/ 找到了一个 link,它说我需要登录构建机器并将 Android NDK 复制并粘贴到我的远程机器上。
但显然使用托管池我无法登录计算机。
我的设置中是否遗漏了什么?
Xamarin论坛上也有同样的问题,解决方法如下:
Fixed: As an update if anyone else having this problem when building Release (that the NDK \toolchains is missing) it appears that mkbundle is broken.
The root cause is that "MakeBundleNativeCodeExternal" is true for release and false for Debug. Although this appears as a licensing issue, my build agent has an Enterprise licence installed.
Disabling "MakeBundleNativeCodeExternal" in Release build by editing the Android project in notepad, seach for 'BundleAssemblies' - and change the 'True' under Release configuration section to ' False' save, build Release, works.
参考这个link了解详情:Missing Android NDK toolchains directory
解决此问题的分步指南。
如果可以,我建议您使用 Visual Studio 2015 Update 2 和 Xamarin 设置您自己的构建主机,并确保 this link. After doing so you can use this Xamarin link。 1. 你的 java SDK 和 NDK 在本地(非用户特定区域,如果你使用 visual studio 安装它们应该是)并且已经添加了环境变量(来自 Xamarin link):
Adjusting Environment Variables During the automated build process Xamarin.Android will require access to the Android SDK and NDK at the paths that were adjusted above. This is best done by setting ot adjusting several server wide environment variables:
If not already, log in to the TFS machine as Administrator. Open Control Panel, type Environment in the search box, select Edit the system environment variables, and then click the Environment Variables... button to bring up the following dialog:
Under System variables select ANDROID_HOME and click Edit…, or if ANDROID_HOME doesn’t exist, click New… to create it:
Set the value to c:\android-sdk (or wherever you moved the SDK) and click OK. Under System variables select ANDROID_NDK_PATH and click Edit… (or New… if necessary):
Set the value to c:\android-ndk\android-ndk-r8d (or wherever you moved the NDK) and click OK. Note that you do need the second folder name in this value. Select the Path variable, click Edit… button, and append ;c:\android-sdk (or whatever folder you used) to the end of the path and click OK. Don’t forget to include the semi-colon (;) separator between this and previous entries.
Verify the changes by opening a command prompt, entering Set, and examining the variables. The Team Foundation Server should now be able to build Android apps in a team project.
在此之后,您必须在 project.Android.csproj 文件中将以下属性设置为 False
。
在记事本中打开文件, 转到发布配置部分 并将以下设置为 false:
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
<BundleAssemblies>False</BundleAssemblies>
您的项目现在将构建在托管池上!
虽然我认为这隐藏了真正的问题,因为将这些设置为 true 将在您的本地构建代理上构建。
我认为 Microsoft 托管池缺少 Android NDK 环境变量,因为它没有出现在 TFS 的功能中
最初的问题是关于在 Azure DevOps 托管代理上构建 Xamarin Android 应用程序并出现错误,因为找不到 Android NDK。
是的,如果您禁用 EmbedAssembliesIntoApk
或 BundleAssemblies
等选项,构建将正常运行,但这不是真正的解决方案,尤其是当您需要启用这些选项时。
由于在托管代理上构建时找不到 Android NDK 路径,因此解决方案是手动设置 Android NDK 路径。 在构建任务的 MSBuild 选项中,提供以下附加参数:
- VS2015 托管代理:
/p:AndroidNdkDirectory="C:\java\androidsdk\android-ndk-r13b"
- VS2017 托管代理:
/p:AndroidNdkDirectory="$(latestAndroidNDKPath)"
如果您想了解有关此问题的更多信息,我写了一篇文章,将为您提供更多详细信息:
如何在 VS2017 托管代理上检索最新的 Android NDK:
$ndk_root = "C:\Microsoft\AndroidNDK64\"
if(Test-Path $ndk_root) {
$androidNDKs = Get-ChildItem -Path $ndk_root | Sort-Object -Property Name -Descending | Select-Object -First 1
$latestAndroidNDK = $androidNDKs.FullName;
Write-Host "##vso[task.setvariable variable=latestAndroidNDKPath]$latestAndroidNDK"
} else {
Write-Host "NDK is not installed at path $ndk_root"
exit 1
}
Write-Host Variable '$(latestAndroidNDKPath)' is $latestAndroidNDK