XAML in Xamarin.Forms 基礎篇 電子書

XAML in Xamarin.Forms 基礎篇 電子書
XAML in Xamarin.Forms 基礎篇 電子書

Xamarin.Forms 快速入門 電子書

Xamarin.Forms 快速入門 電子書
Xamarin.Forms 快速入門 電子書

2016/11/25

VS2017 RC 的 Xamarin.Foms 專案錯誤問題 Could not load assembly Xamarin.Android.Support.v7.RecyclerView

使用VS2017RC 建立好 Xamarin.Forms的專案了。
此時,接下來就是要編譯 Android 專案,可是,重建 Android 專案,卻是失敗的,得到底下的訊息:
所以,按照指示,雙擊這個錯誤訊息,進行安裝這些 Android SDK 內容到 C:\Users\%UserName%\AppData\Local\Xamarin 目錄下
Severity    Code    Description Project File    Line    Suppression State
Error       Project 'App2.Droid' requires the following components installed on your machine: 
Xamarin.Android.Support.v4
JavaLibraryReference: https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip-m2repository/com/android/support/support-v4/23.4.0/support-v4-23.4.0.aar-23.4.0.0
JavaLibraryReference: https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip-m2repository/com/android/support/support-v4/23.4.0/support-v4-23.4.0.aar-23.4.0.0
AndroidResources: https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip-m2repository/com/android/support/support-v4/23.4.0/support-v4-23.4.0.aar-23.4.0.0
Xamarin.Android.Support.Design
JavaLibraryReference: https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip-m2repository/com/android/support/design/23.4.0/design-23.4.0.aar-23.4.0.0
AndroidResources: https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip-m2repository/com/android/support/design/23.4.0/design-23.4.0.aar-23.4.0.0
Xamarin.Android.Support.v7.AppCompat
JavaLibraryReference: https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip-m2repository/com/android/support/appcompat-v7/23.4.0/appcompat-v7-23.4.0.aar-23.4.0.0
AndroidResources: https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip-m2repository/com/android/support/appcompat-v7/23.4.0/appcompat-v7-23.4.0.aar-23.4.0.0
Xamarin.Android.Support.v7.CardView
JavaLibraryReference: https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip-m2repository/com/android/support/cardview-v7/23.4.0/cardview-v7-23.4.0.aar-23.4.0.0
AndroidResources: https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip-m2repository/com/android/support/cardview-v7/23.4.0/cardview-v7-23.4.0.aar-23.4.0.0
Xamarin.Android.Support.v7.MediaRouter
JavaLibraryReference: https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip-m2repository/com/android/support/mediarouter-v7/23.4.0/mediarouter-v7-23.4.0.aar-23.4.0.0
JavaLibraryReference: https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip-m2repository/com/android/support/mediarouter-v7/23.4.0/mediarouter-v7-23.4.0.aar-23.4.0.0
AndroidResources: https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip-m2repository/com/android/support/mediarouter-v7/23.4.0/mediarouter-v7-23.4.0.aar-23.4.0.0


Please double-click here to install it.         0   
再度 重建 Android 專案,卻是失敗的,得到底下的訊息:
Severity    Code    Description Project File    Line    Suppression State
Error       Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Xamarin.Android.Support.v7.RecyclerView, Version=1.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Xamarin.Android.Support.v7.RecyclerView.dll'
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
   at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(DirectoryAssemblyResolver resolver, ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
   at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver)   App3.Droid
看到這樣的訊息,當然是要把 Xamarin.Android.Support.v7.RecyclerView 這個組件從 NuGet 中安裝起來,所以,從 NuGet 中搜尋到這個套件,準備安裝的時候,又遇到底下錯誤訊息。
Severity    Code    Description Project File    Line    Suppression State
Error       Unable to resolve dependencies. 'Xamarin.Android.Support.v7.RecyclerView 23.4.0.1' is not compatible with 'Xamarin.Android.Support.Design 24.2.1 constraint: Xamarin.Android.Support.v7.RecyclerView (= 24.2.1)'.           0   
根據這個訊息,似乎是 ‘Xamarin.Android.Support.v7.RecyclerView 23.4.0.1’ 這個套件,不相容於 ‘Xamarin.Android.Support.Design 24.2.1’ 這個套件的限制,當然就要裝 ‘Xamarin.Android.Support.v7.RecyclerView 24.2.1’ 套件呀;結果是得到底下的錯誤,看樣子,好像與前面的錯誤訊息都是一樣。
Severity    Code    Description Project File    Line    Suppression State
Error       Unable to resolve dependencies. 'Xamarin.Android.Support.v7.RecyclerView 24.2.1' is not compatible with 'Xamarin.Android.Support.Design 24.2.1 constraint: Xamarin.Android.Support.v7.RecyclerView (= 24.2.1)'.         0   
回來檢查這個 Android 原生專案內的 ‘Xamarin.Android.Support.Design’ 套件,發現到此時安裝的是 23.4.0.1,這倒有點讓人混亂了。
enter image description here
好吧,那就試著升級 ‘Xamarin.Android.Support.Design’ 套件到 24.2.1 版本好了,可是,卻得到底下錯誤訊息。
Severity    Code    Description Project File    Line    Suppression State
Error       Unable to resolve dependencies. 'Xamarin.Android.Support.Design 24.2.1' is not compatible with 'Xamarin.Forms 2.3.3.168 constraint: Xamarin.Android.Support.Design (= 23.3.0)'.         0   
看樣子,又得把 ‘Xamarin.Forms’ 套件升級到 2.3.3.168,不過,當要升級的時候,又得到底下錯誤訊息:
Severity    Code    Description Project File    Line    Suppression State
Error       Unable to resolve dependencies. 'Xamarin.Android.Support.Compat 24.2.1' is not compatible with 'Xamarin.Android.Support.Design 24.2.1 constraint: Xamarin.Android.Support.Compat (= 24.2.1)'.           0   
恩恩,情況不妙,看樣子,這個 Xamarin.Forms 的專案,透過 Visual Studio 2017 RC 所建立起來的專案,有問題。
二話不囉說,安裝 Prism Template Pack 擴充套件,產生一個 Prism 的 Xamarin.Forms 的專案,完美,可以正常編譯。
enter image description here

沒有留言:

張貼留言