2
votes

I am using Xamarin Forms with visual studio 2017 .. the new project is always has Xamarin.Forms v 2.3.3.191. The project doesn't work .. it stops on (InitializeComponent) on the MainPage .. just stops and nothing happening. I thought the problem is with Xamarin.Forms version, so I installed the update of Xamarin.Forms .. the version 2.5.0.121934 (Last Stable) Then when I rebulid the Android project it gives me that error

Severity Code Description Project File Line Suppression State Error Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Xamarin.Android.Support.Fragment, Version=1.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile? File name: 'Xamarin.Android.Support.Fragment.dll'

And these are the packages

<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.Design" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v4" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v7.AppCompat" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v7.CardView" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v7.MediaRouter" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Forms" version="2.5.0.121934" targetFramework="monoandroid60" />

I tried to update Xamarin.Android.Support.v7.AppCompat but it gives me an error

Severity Code Description Project File Line Suppression State Error Unable to resolve dependencies. 'Xamarin.Android.Support.v7.AppCompat 26.1.0.1' is not compatible with 'Xamarin.Forms 2.5.0.122203 constraint: Xamarin.Andr

Now I have two cases:

  1. Updating X.F to version 2.5.... and that throws an error System.IO.FileNotFoundException: Could not load assembly 'Xamarin.Android.Support.Fragment at rebuilding android project]
  2. Keep the X.F version at 2.4.... and that make the app crushes at some points

I am working with Android 6 Marshmallow API 23

PLEASE HELP ME

1
Change the Target Framework of your project to at least Android 7.0, if you need the latest Google AppCompat libaries, you need to target Android 8.0SushiHangover
Ok, I have installed android 7 (API 24) from SDK manager, but the error still appears .. when I googled that I found that I must install android 8 .. and this image ibb.co/bDr0bb is my android 8 on SDK ..I have installed the SDK Platform, but I didn't find android 8 on Target platform on vs, so what else I must install ?Amir Imam
Have you tried using the new (Preview) Xamarin Android Device Manager?Eren Shen
Any solution on this? I have the same issueZotyi
Yes, if you want to use Xamarin.Forms 2.5.x than you have to update visual studio 2017 to version 15.5.x and install android API level 26 .. or you can use Xamarin.Forms 2.4.x without updating visual studioAmir Imam

1 Answers

1
votes

I solved the same issue by setting the Android Target Framework (not to be confused with the Android Target Version) to Android 7.0 as described in the Xamarin.Forms 2.5.0 release notes:

With Xamarin.Forms 2.3.4, the restriction limiting developers to Android Support Library 23 was lifted allowing developers to choose new Google Play Services and Android Support Library dependencies. This opens up more possibilities and flexibilities for developers, but also vastly complicates resolving dependencies in projects using different libraries. Now in Xamarin.Forms 2.5.0, in order to support Google Play Services 42.1024.0 or greater, Xamarin.Forms depends on Android Support Libraries 25.4.0.2 or greater.

When using Xamarin.Forms 2.5.0, be sure to start with a baseline of these dependencies as appropriate to your project. This is the combination of dependencies with which Xamarin.Forms has been tested.

  • Android Target Framework 7.0 (monoAndroid70)
  • Android Support Libraries 25.4.0.2
  • Google Play Services 42.1024.0

Afterwards I deleted the Xamarin.Forms package and all its referencing Android Support packages and reinstalled Xamarin.Forms version 2.5. However, this kept always the Android Support libraries in version 23.3 being installed. By choosing Update from the Xamarin.Forms package's context menu the correct Android Support Libraries in version 25.4.0.2 were installed.