Load Image from URL into ImageView in Xamarin Android - xamarin.android

I am working on an app and want to bind the Image URL in image view of recycler i want to use picaso for this but every time when I add nuget package I'll got an error.
System.IO.FileNotFoundException: Could not load assembly 'Square.OkHttp, Version=2.7.5.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
Please suggest

It's displaying the error because it requires the add-on libraries OkHttp and OkIO. Add the package for Picasso and try again.

Related

One or more reference to type UIKit.UIWebView

We are aware that in Xamarin.iOS, UIWebView will soon be deprecated and apps will not be accepted with deprecated versions.
I have created a new project here. I have followed this document here as well as other posts on internet to remove UIWebkit and replace it with WKWebview but it doesnt work.
Since its a new project, so no nuget packages are being used which could have had UIWebView. But still when i add --warn-on-type-ref=UIKit.UIWebView flag in mtouch arguments I get error:
One or more reference(s) to type 'UIKit.UIWebView' already exists
inside 'Xamarin.Forms.Platform.iOS, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=null' before linking WebViewTest.iOS
How do I remove UIWebview complete from the basic project so my app can get accepted on testflight/appstore.
I am using Visual Studio 16.5.5 with Xamarin.iOS version 13.16 and I have tested on Xamarin forms 4.4 and 4.6 both
In project file WebViewTest.iOS.csproj remove --warn-on-type-ref=UIKit.UIWebView -warnaserror:1502 -warnaserror:1503
It should look like this
<MtouchExtraArgs>--optimize=experimental-xforms-product-type</MtouchExtraArgs>
Use latest Visual Studio for Mac
also set Linker behavior to SDK framework only or All - this is important

The "LinkAssemblies" task failed unexpectedly in Xamarin Android

I am trying to POST data using a REST API. The app used to run flawlessly, but now that I've added code to perform the POST, I'm getting a new error. Would anyone be able to help explain what's going wrong and suggest an alternative that would let me complete the POST request successfully?
Here's the error I get when I try to build the app with the linker enabled in the Release configuration:
Error The "LinkAssemblies" task failed unexpectedly.
Xamarin.Android.XamarinAndroidException: error XA2006: Reference to metadata item 'System.Runtime.InteropServices.StandardOleMarshalObject' (defined in 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') from 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' could not be resolved. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Runtime.InteropServices.StandardOleMarshalObject
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.InitializeType(TypeDefinition type)
at Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.Initialize()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
--- End of inner exception stack trace ---
at Xamarin.Android.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() GimcoIOT.Andriod
It looks like you might have added a reference to a desktop .NET assembly in your Xamarin.Android app. The System.Windows.Forms namespace is not available in the Xamarin.Android profile. (Even if the app builds successfully when you disable linking, it will in theory still fail at run time any time it tries to run code that references the System.Windows.Forms namespace.)
To solve this problem, you will want to remove the reference to the desktop .NET assembly from your Xamarin.Android project and ensure that all of your other referenced assemblies are compiled either against the Xamarin.Android profile or a supported PCL profile.
As mentioned in the documentation:
Xamarin.Android is not ABI compatible with existing assemblies compiled for a different profile. You must recompile your source code to generate assemblies targeting the Xamarin.Android profile (just as you need to recompile source code to target Silverlight and .NET 3.5 separately).
(Portable Class Libraries are the special exception to this rule.)
If you are currently using a type from the System.Windows.Forms namespace to perform the POST request, then you will need to switch to a different type. For example, one of the PostAsync() methods from System.Net.Http.HttpClient might work nicely.

Reference to type 'System.IConvertible' claims it is defined in assembly mscorlib

Anytime I try to reference an NUNIT data type in the iOS framework, I am given a compiler error saying it can't find the IConvertible type
Error CS7069: Reference to type System.IConvertible' claims it is defined assemblymscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089', but it could not be found (CS7069) (logic)
I was able to reproduce this by creating a brand new Xamarin.Forms project that only targets iOS.
Immediately after creating it, I added a second Xamarin.Forms project, this time a PCL.
I then needed to add the Xamarin.iOS library so that I can reference the iOS specific APIs, specifically the Photos API. I did this by navigating to
~/Library/Frameworks/Xamarin.iOS.framework/Versions/9.0.1.29/lib/mono/Xamarin.iOS/Xamarin.iOS.dll
Lastly, I added a blank class to the new PCL project, and created a locally scoped NUNIT field. This is where the compiler error happens. This happens in my current project when I try to get the number of photos in a PHAssetCollection, as that is an NUNIT data type.
using System;
namespace logic
{
public class EmptyClass
{
public EmptyClass()
{
nuint test = 5;
}
}
}
This gives me the compiler error I've referenced above. How can I solve this? This has become a blocking issue for me, am I referencing the wrong Xamarin.iOS.dll? It's not available in the list of nuget packages when I scan for them, so I can't add it via NuGet. NuGet only has Xamarin.Forms.dll available.
Update 1
After trying a few different combinations, I think that I have a working solution. Instead of creating a Xamarin.Forms Library, I created a normal iOS PCL library instead. This solved that problem.
I don't know why the Xamarin.Forms library wouldn't work. Is it not intended to be used for platform specific code?
Xamarin Forms PCL's need to be platform agnostic. If you have a NUnit project that needs access to a Xamarin.iOS specific reference, then you need to build within the iOS project / iOS PCL.
Xamarin.iOS.dll can only be referenced from a iOS related project.

Persistent issue with Xam.Forms Lab on Android

I have a multiplatform app using Xamarin.Forms. While I can build for iOS and WindowsPhone 8.1, when I build for Android, I get the following build error
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: error : Error executing task LinkAssemblies: error XA2006: Reference to metadata item 'System.Void Android.OS.BaseBundle::PutString(System.String,System.String)' (defined in 'XLabs.Platform.Droid, Version=2.0.5679.29813, Culture=neutral, PublicKeyToken=null') from 'XLabs.Platform.Droid, Version=2.0.5679.29813, Culture=neutral, PublicKeyToken=null' could not be resolved.
I've searched around for a solution on this but cannot seem to find one or where on earth in my code this problem is coming from.
Does anyone know how to start solving this issue so I can submit a build?
Check that the Xamarin Forms NuGet package versions are the same in the XLabs version you are using and the Android Project. Normally a version mismatch is the cause for these errors.

Oxyplot Run Xamarin forms iOS not found ref to OxyPlot.Xamarin.iOS

I am creating an application in Xamarin Forms and I'll show graphs with OxyPlot, running the Hello World OxyPlot on Android and Windows Phone running, but I have a problem with IOS. When the emulator loads the application sends the following:
{System.IO.FileNotFoundException: Could not load file or assembly ‘OxyPlot.Xamarin.iOS’}
and the stack:
System.AppDomain.Load (assemblyRef={OxyPlot.Xamarin.iOS, Version=2015.1.889.0, Culture=neutral, PublicKeyToken=null}, assemblySecurity=(null)) in /Users/builder/data/lanes/1962/8b265d64/source/mono/mcs/class/corlib/System/AppDomain.cs:706
it seems that does not refer to Packete Oxyplot.xamarin.iOS but not how to solve it.
I have added Nuget pre-release of OxyPlot Xamarin Forms, in each platform. As I mentioned in android and windows phone (using visual studio) is working properly.
I appreciate your attention and stay tuned if more data is needed.
greetings
Make sure you have https://www.nuget.org/packages/OxyPlot.Xamarin.Forms/ installed. Then, you need to initialize the OxyPlot renderers by adding the following call just before Xamarin.Forms.Forms.Init():
iOS: OxyPlot.Xamarin.Forms.Platform.iOS.Forms.Init();
Android: OxyPlot.Xamarin.Forms.Platform.Android.Forms.Init();
WinPhone: OxyPlot.Xamarin.Forms.Platform.WinPhone.Forms.Init();
OR
It's possible that assembly is cut because of Xamarin linker. Add:
var ignoreOxyplot = typeof(OxyPlot.Xamarin.Forms.Platform.iOS.PlotViewRenderer) in iOS project FinishedLaunching method.
See: http://forums.xamarin.com/discussion/comment/122219

Resources