简体   繁体   English

Xamarin.Forms 不编译 Android 项目

[英]Xamarin.Forms does not compile an Android Project

Again, after updating to VS 8.9.1 on Mac I'm getting this error while trying to compile my Android project:同样,在 Mac 上更新到 VS 8.9.1 后,我在尝试编译我的 Android 项目时遇到了这个错误:

    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Tooling.targets(5,5): Error XARSD7023: System.IO.DirectoryNotFoundException: Could not find a part of the path '/Users/giulioserra/Library/Android/sdk'.
  at System.IO.Enumeration.FileSystemEnumerator`1[TResult].CreateDirectoryHandle (System.String path, System.Boolean ignoreNotFound) [0x00032] in <36514b14425c4337b446653c547aa9c3>:0 
  at System.IO.Enumeration.FileSystemEnumerator`1[TResult]..ctor (System.String directory, System.IO.EnumerationOptions options) [0x00048] in <36514b14425c4337b446653c547aa9c3>:0 
  at System.IO.Enumeration.FileSystemEnumerable`1+DelegateEnumerator[TResult]..ctor (System.IO.Enumeration.FileSystemEnumerable`1[TResult] enumerable) [0x00000] in <36514b14425c4337b446653c547aa9c3>:0 
  at System.IO.Enumeration.FileSystemEnumerable`1[TResult]..ctor (System.String directory, System.IO.Enumeration.FileSystemEnumerable`1+FindTransform[TResult] transform, System.IO.EnumerationOptions options) [0x00042] in <36514b14425c4337b446653c547aa9c3>:0 
  at System.IO.Enumeration.FileSystemEnumerableFactory.UserDirectories (System.String directory, System.String expression, System.IO.EnumerationOptions options) [0x00014] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corefx/src/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerableFactory.cs:104 
  at System.IO.Directory.InternalEnumeratePaths (System.String path, System.String searchPattern, System.IO.SearchTarget searchTarget, System.IO.EnumerationOptions options) [0x00045] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corefx/src/System.IO.FileSystem/src/System/IO/Directory.cs:180 
  at System.IO.Directory.EnumerateDirectories (System.String path, System.String searchPattern, System.IO.EnumerationOptions enumerationOptions) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corefx/src/System.IO.FileSystem/src/System/IO/Directory.cs:196 
  at System.IO.Directory.EnumerateDirectories (System.String path, System.String searchPattern, System.IO.SearchOption searchOption) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corefx/src/System.IO.FileSystem/src/System/IO/Directory.cs:193 
  at Xamarin.Android.Tools.AndroidSdkBase.FindBestNDK (System.String androidSdkPath) [0x00038] in /Users/builder/azdo/_work/278/s/xamarin-android/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkBase.cs:172 
  at Xamarin.Android.Tools.AndroidSdkBase+<GetAllAvailableAndroidNdks>d__73.MoveNext () [0x000d0] in /Users/builder/azdo/_work/278/s/xamarin-android/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkBase.cs:164 
  at Xamarin.Android.Tools.AndroidSdkBase.GetValidNdkPath (System.String ctorParam) [0x00068] in /Users/builder/azdo/_work/278/s/xamarin-android/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkBase.cs:128 
  at Xamarin.Android.Tools.AndroidSdkBase.Initialize (System.String androidSdkPath, System.String androidNdkPath, System.String javaSdkPath) [0x00061] in /Users/builder/azdo/_work/278/s/xamarin-android/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkBase.cs:71 
  at Xamarin.Android.Tools.AndroidSdkInfo..ctor (System.Action`2[T1,T2] logger, System.String androidSdkPath, System.String androidNdkPath, System.String javaSdkPath) [0x00025] in /Users/builder/azdo/_work/278/s/xamarin-android/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/AndroidSdkInfo.cs:18 
  at Xamarin.Android.Tasks.MonoAndroidHelper.RefreshAndroidSdk (System.String sdkPath, System.String ndkPath, System.String javaPath, Microsoft.Build.Utilities.TaskLoggingHelper logHelper) [0x00005] in <e0b267300cf54583bbaa8d3ab5dc4081>:0 
  at Xamarin.Android.Tasks.ResolveSdks.RunTask () [0x000ac] in <e0b267300cf54583bbaa8d3ab5dc4081>:0 
  at Xamarin.Android.Tasks.AndroidTask.Execute () [0x00000] in <e0b267300cf54583bbaa8d3ab5dc4081>:0  (XARSD7023) (HangoverBusiness.Android)

I tried to delete bin and obj files but nothing, this problem only manifests in the Android project, while the IOS version works fine.我试图删除 bin 和 obj 文件但没有,这个问题只出现在 Android 项目中,而 IOS 版本工作正常。

Env: Mac OS Catalina VS 8.9.1环境:Mac OS Catalina VS 8.9.1

Any hint?有什么提示吗?

Workaround is now added in prerelease.现在在预发行版中添加了解决方法。

https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2019-mac-preview-relnotes https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2019-mac-preview-relnotes

Workaround:- In some cases, Android projects may fail to build with an error The Java SDK could not be found, please set the path to it in the Xamarin.Android SDKs settings panel. Workaround:- In some cases, Android projects may fail to build with an error The Java SDK could not be found, please set the path to it in the Xamarin.Android SDKs settings panel. A workaround is to execute the following command in a Terminal:一种解决方法是在终端中执行以下命令:

mkdir -p ~/Library/Android/sdk

Looking at the developer community portal this is a bug introduced in v8.9.1.查看开发者社区门户,这是 v8.9.1 中引入的一个错误 It also specifies a workaround: manually copy the Android SDK files from the default path (found in the settings screen, see below) to the hardcoded path in the error message.它还指定了一种解决方法:手动将 Android SDK 文件从默认路径(在设置屏幕中找到,见下文)复制到错误消息中的硬编码路径。 In your case /Users/giulioserra/Library/Android/sdk在你的情况下/Users/giulioserra/Library/Android/sdk

Android 默认 SDK 路径

A better way for me instead of copying the files is a symbolic link, because I use the Android sdk for multiple applications and users and it takes much disk space.对我来说,一个比复制文件更好的方法是符号链接,因为我对多个应用程序和用户使用 Android sdk 并且占用大量磁盘空间。 The symlink solution worked for me:符号链接解决方案对我有用:

ln -s /Path/to/real/sdk /Path/from/error/message

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM