6

Xamarin 解决创建空白项目编译提示 linking references 找不到资源

 3 years ago
source link: https://lindexi.gitee.io/post/Xamarin-%E8%A7%A3%E5%86%B3%E5%88%9B%E5%BB%BA%E7%A9%BA%E7%99%BD%E9%A1%B9%E7%9B%AE%E7%BC%96%E8%AF%91%E6%8F%90%E7%A4%BA-linking-references-%E6%89%BE%E4%B8%8D%E5%88%B0%E8%B5%84%E6%BA%90.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Xamarin 解决创建空白项目编译提示 linking references 找不到资源

在新建一个 Xamarin 应用,编译时提示了 linking references 和一些诡异的文件无法访问,原因是文件路径问题和 NuGet 还原问题

如果创建的 Xamarin 项目所在的文件路径比较深,同时包含中文等字符时,在编译时可以会诡异失败

oid\Xamarin.Android.Aapt2.targets(155,3): error APT2062: failed linking references.
error APT0000: resource integer/google_play_services_version (aka com.softoursistemas.rutesc.droid:integer/google_play_services_version) not found

也有比较明确的提示

Failed to create JavaTypeInfo for class: Android.Support.V13.View.Inputmethod.InputConnectionCompat/IOnCommitContentListenerImplementor due to MAX_PATH: System.IO.DirectoryNotFoundException: 未能找到路径“g:\lindexi\ChuwheaweaharfelkalBelqearjurnawnere\ChuwheaweaharfelkalBelqearjurnawnere\ChuwheaweaharfelkalBelqearjurnawnere.Android\obj\Debug\90\android\src\mono\android\support\v13\view\inputmethod\InputConnectionCompat_OnCommitContentListenerImplementor.java”的一部分。
   在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   在 System.IO.File.InternalDelete(String path, Boolean checkHost)
   在 System.IO.File.Delete(String path)
   在 Xamarin.Android.Tools.Files.CopyIfStreamChanged(Stream stream, String destination)
   在 Xamarin.Android.Tasks.Generator.CreateJavaSources(TaskLoggingHelper log, IEnumerable`1 javaTypes, String outputPath, String applicationJavaClass, String androidSdkPlatform, Boolean useSharedRuntime, Boolean generateOnCreateOverrides, Boolean hasExportReference)	ChuwheaweaharfelkalBelqearjurnawnere.Android	

也有很诡异的提示

Android\obj\Debug\90\lp\39\jl\res : error APT2097: failed to open directory: 绯荤粺

有明确的提示的可以看到,其实 Xamarin 的设计有点坑,就是路径太长了,加上了我的项目命名,在 Windows 下的路径就超过了 260 字符限制,此时就编译不通过

解决方法是尝试将项目移动到磁盘的第二级文件夹,然后使用删除所有的 binobj 文件夹,此时就可以解决这几个诡异的坑

Failed linking references in Android project (Xamarin - Visual Studio Community 2019) · Issue #3822 · xamarin/xamarin-android

Create a new Mobile.App (Xamarin.Forms) project, try to compile, but “Failed linking references” - Stack Overflow


本文会经常更新,请阅读原文: https://blog.lindexi.com/post/Xamarin-%E8%A7%A3%E5%86%B3%E5%88%9B%E5%BB%BA%E7%A9%BA%E7%99%BD%E9%A1%B9%E7%9B%AE%E7%BC%96%E8%AF%91%E6%8F%90%E7%A4%BA-linking-references-%E6%89%BE%E4%B8%8D%E5%88%B0%E8%B5%84%E6%BA%90.html ,以避免陈旧错误知识的误导,同时有更好的阅读体验。

如果你想持续阅读我的最新博客,请点击 RSS 订阅,推荐使用RSS Stalker订阅博客,或者前往 CSDN 关注我的主页

本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。欢迎转载、使用、重新发布,但务必保留文章署名林德熙(包含链接: https://blog.lindexi.com ),不得用于商业目的,基于本文修改后的作品务必以相同的许可发布。如有任何疑问,请 与我联系

无盈利,不卖课,做纯粹的技术博客

以下是广告时间

推荐关注 Edi.Wang 的公众号

lindexi%2F201985113622445

欢迎进入 Eleven 老师组建的 .NET 社区

lindexi%2F20209121930471745.jpg

以上广告全是友情推广,无盈利


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK