Xamarin.Forms Errors

Xamarin.Forms Errors

Working with Xamarin.Forms is fun.

But even in fun time, you get some trouble, and the following are the main Errors that stopped my work, with their solutions:

 🔘 Errors:

Error Unzipping failed. Please download https://dl-ssl.google.com/android/repository/android_m2repository_r22.zip and extract it to the C:\Users\[user profile]\AppData\Local\Xamarin\Android.Support.Design\23.0.1.3\content directory. App4.Droid
Error Reason: C:\Users\[user profile]\AppData\Local\Xamarin\zips\96659D653BDE0FAEDB818170891F2BB0.zip is not a valid zip file App4.Droid
Error Please install package: ‘Xamarin.Android.Support.Design’ available in SDK installer. Java library file C:\Users\[user profile]\AppData\Local\Xamarin\Android.Support.Design\23.0.1.3\embedded\classes.jar doesn’t exist. App4.Droid
Error Unzipping failed. Please download https://dl-ssl.google.com/android/repository/android_m2repository_r22.zip and extract it to the C:\Users\[user profile]\AppData\Local\Xamarin\Android.Support.Design\23.0.1.3\content directory. App4.Droid
Error Reason: C:\Users\[user profile]\AppData\Local\Xamarin\zips\96659D653BDE0FAEDB818170891F2BB0.zip is not a valid zip file App4.Droid
ror Please install package: ‘Xamarin.Android.Support.v7.MediaRouter’ available in SDK installer. Android resource directory C:\Users\[user profile]\AppData\Local\Xamarin\Android.Support.v7.MediaRouter\23.0.1.3\embedded\./ doesn’t exist. App4.Droid

.

Solved by doing:
https://forums.xamarin.com/discussion/60584/xamarin-zips-96659d653bde0faedb818170891f2bb0-zip-is-not-a-valid-zip-file
as Mr. @ShubhamTholiya said:
Navigate to C:\Users\[user-name]\AppData\Local\Xamarin\zips
C:\Users\[user profile]\AppData\Local\Xamarin\zips
Delete 96659D653BDE0FAEDB818170891F2BB0.zip file from the folder.
Delete /.bin & /.obj folders from your project location.
Clean and Rebuild your project.

.
 🔘 Error No valid iOS code signing keys found in keychain. You need to request a codesigning certificate from https://developer.apple.com. App3.iOS

.

Solved by the following urls:
https://forums.xamarin.com/discussion/39674/iphonesimulator-build-results-in-no-valid-ios-code-signing-keys-found-in-keychain
https://bugzilla.xamarin.com/show_bug.cgi?id=29654
http://forums.xamarin.com/discussion/comment/63318/#Comment_63318

.

🔘 Error No installed provisioning profiles match the installed iOS code signing keys. App3.iOS

.

Solved by the following urls:
https://forums.xamarin.com/discussion/13497/error-no-installed-provisioning-profiles-match-the-installed-ios-code-signing-keys
https://developer.xamarin.com/guides/ios/getting_started/installation/device_provisioning/
http://stackoverflow.com/questions/30724551/no-installed-provisioning-profiles-match-the-installed-ios-code-signing-keys-in

.

🔘 Error Unable to find a version of ‘Xamarin.Android.Support.v4’ that is compatible with ‘Xamarin.Android.Support.Animated.Vector.Drawable 23.2.1 constraint: Xamarin.Android.Support.v4 (= 23.2.1)’

.

Solved by:
run “SDK Manager” as Admin, and install all the relevant Android SDKs and update them.

.

🔘 Error The file “obj\Debug\android\bin\packaged_resources” does not exist. App9.Droid
http://stackoverflow.com/questions/32292577/android-app-compile-not-generating-package-resources

.
Solved by:
make sure that the resources folder in Droid + iOS, like images, have names that confirm to “must contain only [a-z0-9_.]

.
🔘 Error CS0119 ‘DependencyService.Get<T>(DependencyFetchTarget)’ is a method, which is not valid in the given context App9 D:\Docs\Documents\Visual Studio 2015\Projects\App9\App9\App9\Data\Database.cs 19 Active

.

Solved by:
Make the same class in all projects, and compile them, so the dependency works as seen here:
https://developer.xamarin.com/guides/xamarin-forms/dependency-service/introduction/

.

🔘 Warning iCCP: Not recognizing known sRGB profile that has been edited Trainer.Droid …\Trainer.Droid\obj\Debug\res\drawable\pic_accounting_with_excel__level_1_2.png

.
Solved by:
using “exiftool”
http://www.sno.phy.queensu.ca/~phil/exiftool/
This command worked:

exiftool -overwrite_original “[PicturePath].png” -all=

or try ImageMagick
http://www.imagemagick.org/script/command-line-processing.php

Get Rid of – iCCP: Not recognizing known sRGB profile that has been edited

These did not work for me:
find . -path ‘[PicturePath]\_Pics\Tmp\*’ -name ‘*.png’ -exec exiftool(-k) -overwrite_original -all= {} \;
exiftool -overwrite_original -all= {} \;
exiftool -overwrite_original -all “[PicturePath].png”

.

🔘 Error java.lang.OutOfMemoryError. Consider increasing the value of $(JavaMaximumHeapSize). Java ran out of memory while executing ‘java.exe -jar “…”
from https://forums.xamarin.com/discussion/2132/java-heap-space-outofmemoryerror-when-binding-a-big-jar

.
Solved by:

Edit the **.Droid.csproj**, search for all occurrences of “JavaMaximumHeapSize”, and make them:

<PropertyGroup>
<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
</PropertyGroup>

and if you did not find them, add them under all occurrences of **<PropertyGroup>**

.

🔘 Error Build action ‘EmbeddedResource’ is not supported by one or more of the project’s targets.

.

Solved by:
Try this url:
https://readerman1.wordpress.com/2016/05/11/xamarin-build-action-embeddedresource-is-not-supported-by-one-or-more-of-the-projects-targets/

.

🔘 Warning Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning
(or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the “runtime” node in the application configuration file:
<assemblyBinding xmlns=”urn:schemas-microsoft-com:asm.v1″><dependentAssembly><assemblyIdentity name=”XLabs.Serialization” culture=”neutral” publicKeyToken=”d65109b36e5040e4″ /><bindingRedirect oldVersion=”0.0.0.0-2.0.5782.15703″ newVersion=”2.0.5782.15703″ /></dependentAssembly></assemblyBinding>
<assemblyBinding xmlns=”urn:schemas-microsoft-com:asm.v1″><dependentAssembly><assemblyIdentity name=”Newtonsoft.Json” culture=”neutral” publicKeyToken=”30ad4fe6b2a6aeed” /><bindingRedirect oldVersion=”0.0.0.0-8.0.0.0″ newVersion=”8.0.0.0″ /></dependentAssembly></assemblyBinding> Trainer.Droid
Severity Code Description Project File Line Suppression State
Warning Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the “runtime” node in the application configuration file: <assemblyBinding xmlns=”urn:schemas-microsoft-com:asm.v1″><dependentAssembly><assemblyIdentity name=”XLabs.Serialization” culture=”neutral” publicKeyToken=”d65109b36e5040e4″ /><bindingRedirect oldVersion=”0.0.0.0-2.0.5782.15703″ newVersion=”2.0.5782.15703″ /></dependentAssembly></assemblyBinding> Trainer.Droid

https://forums.xamarin.com/discussion/40732/dependent-assembly-version-conflict-binding-redirects
http://mikehadlow.blogspot.co.uk/2011/02/asmspy-little-tool-to-help-fix-assembly.html
https://github.com/mikehadlow/AsmSpy
https://social.msdn.microsoft.com/Forums/vstudio/en-US/996da222-8dee-4ba6-88ec-5d9f96f495c3/found-conflicts-between-different-versions-of-the-same-dependent-assembly-that-could-not-be-resolved?forum=lightswitch

.

🔘 Error: “Unable to find a version of Xamarin.Forms compatible with…”
https://developer.xamarin.com/guides/xamarin-forms/troubleshooting/
http://screencast.com/t/U5FBj6KlH

.
🔘 Error: You need to add a reference to Mono.Android.Export.dll when you use ExportAttribute or ExportFieldAttribute. testXFPre.Droid C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 1574
Right click references and search Export. Just add the export.dll to your project.
from this url:
http://stackoverflow.com/questions/31085554/you-need-to-add-a-reference-to-mono-android-export-dll-when-you-use-exportattrib

.

🔘 Error: CS0103 The name ‘InitializeComponent’ does not exist in the current context TrainerC D:\4_Prj\Training\TrainerC\TrainerC\TrainerC\MVC\Forms\AboutDeveloper.xaml.cs 16 Active

You might get this error when you import a class from another project, or change the path of the xaml file, or the namespace of either the xaml or behind .cs file.

One: It might have a namespace that is not the same as what you have in you new project

namespace TrainerB.MVC.Forms
{
     public partial class AboutDeveloper : ContentPage
     {
          public AboutDeveloper()
          {
               InitializeComponent();
          }
     }
}

As you can see the name space in the imported file begins with the old project name: “TrainerB”, but your new project might have a different name, so just change it to the correct new project name, in both the .xaml file and the behind .cs file.

Two: change the properties of the .xaml file to:

Build Action: Embedded Resource

Custom Tool: MSBuild:UpdateDesignTimeXaml

this was answered here:

http://stackoverflow.com/questions/6925584/the-name-initializecomponent-does-not-exist-in-the-current-context/37244185#37244185

Xaml file properties Xaml Namespace Correcting 01 Xaml Namespace Correcting 02

.

🔘 Error: System.InvalidOperationException: PushAsync is not supported globally on Android, please use a NavigationPage.

🔘 Error: PushAsync is not supported globally on Windows, please use a NavigationPage.
at Xamarin.Forms.Platform.WinRT.Platform.Xamarin.Forms.INavigation.PushAsync(Page root, Boolean animated)
at Xamarin.Forms.NavigationProxy.OnPushAsync(Page page, Boolean animated)
at Xamarin.Forms.NavigationProxy.PushAsync(Page root, Boolean animated)
at Xamarin.Forms.NavigationProxy.PushAsync(Page root)
at testSyncfusion.MVC.MainPage.btnCourseList_Clicked(Object sender, EventArgs e)
at Xamarin.Forms.Button.Xamarin.Forms.IButtonController.SendClicked()
at Xamarin.Forms.Platform.WinRT.ButtonRenderer.OnButtonClick(Object sender, RoutedEventArgs e)

You are calling “PushAsync”:

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
    }

    private void btnCourseList_Clicked(object sender, EventArgs e)
    {
        Navigation.PushAsync(new PageB());
    }
}

but you did not start the NavigationPage, which normally is done in the App.cs class, or at least it should be started before any call to “PushAsync”:

MainPage = new NavigationPage(new PageA());

This is posted here: http://stackoverflow.com/questions/24621814/pushasync-is-not-supported-globally-on-android-please-use-a-navigationpage-xa/37244322#37244322

Or

http://stackoverflow.com/questions/24621814/pushasync-is-not-supported-globally-on-android-please-use-a-navigationpage-xa

make sure that your main page when you call it in the App.cs, is contained in a Navigation page.
e.g., don’t use:


MainPage = new MainPage();

use:


NavigationPage page = new NavigationPage(new MainPage());
MainPage = page;

 

🔘 Error: {“Unable to load DLL ‘sqlite3’: The specified module could not be found. (Exception from HRESULT: 0x8007007E)”}
🔘 Error: Additional information: Unable to load DLL ‘sqlite3’: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
🔘 Error: Unable to load DLL ‘sqlite3’: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at SQLite.Net.Platform.WinRT.SQLite3.SetDirectory(UInt32 directoryType, String directoryPath)
at SQLite.Net.Platform.WinRT.SQLiteApiWinRT..ctor()
at SQLite.Net.Platform.WinRT.SQLitePlatformWinRT..ctor()
at SQLiteEx.UWP.SqliteService.GetConnection()
at testSyncfusion.DataAccess.create()
at testSyncfusion.MVC.MainPage.btnTestSQLite_Clicked(Object sender, EventArgs e)
at Xamarin.Forms.Button.Xamarin.Forms.IButtonController.SendClicked()
at Xamarin.Forms.Platform.UWP.ButtonRenderer.OnButtonClick(Object sender, RoutedEventArgs e)

Solution:
SQLite + UWP (Universal Windows):
SQLite for Universal Windows Platform vsix
from here SQLite-UWP :
https://visualstudiogallery.msdn.microsoft.com/4913e7d5-96c9-4dde-a1a1-69820d615936
or from here:
http://sqlite.org/download.html

SQLite + UWP install SQLite for Universal Windows Platform
then after installing the .vsix, go to References node under the .UWP project, and right click, and select “Add reference”
then Universal Windows\Extensions\SQLite for Universal Windows Platform vsix [Tick the check box]
+ Universal Windows\Extensions\Visual C++ 2015 Runtime for Universal Windows Platform Apps

http://stackoverflow.com/questions/31042772/unable-to-load-dll-sqlite3-in-sqlite-net-platform-winrt

SQLite + UWP install

If the above did not work, try this:

http://stackoverflow.com/questions/31851012/unable-to-load-dll-sqlite3-in-universal-windows-app-running-on-mobile

 

🔘 Error: Cannot find type System.ComponentModel.TypeConverter in module System.dll. testSyncfusion.UWP C:\Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v14.0\8.2\Microsoft.Windows.UI.Xaml.Common.targets 352

Sometimes you might erroneously put a reference to “Mono.Android.dll” inside the UWP Project, so take it off.
or
Try taking of the references To:
Visual C++ 2015 Run-time for Universal Windows Platform Apps.
But check sqlite if it works or not.

 

🔘 Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly ‘SocketIoClientDotNet, Version=0.9.12.0, Culture=neutral, PublicKeyToken=’. Perhaps it doesn’t exist in the Mono for Android profile?
File name: ‘SocketIoClientDotNet.dll’
at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.Execute() testSyncfusion.Droid C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 1408 
This is used by Gorilla Player, which means that either you should take off gorilla .dlls from the projects references, or install gorilla player in your system.

 

🔘 Error: Failing to deploy your app to Microsoft Visual Studio Emulator in debug mode

My fix, came By going to the .Droid project, and selecting its properties, then go to:
Android Options\Packaging Tab\
then un-tick both [Use shared Runtime] + [Use Fast Deployment (debug mode only)]
Save the changes.
then immediately tick both of them back on.
and that’s it.
the problem, is that you need to do that every time you are going to debug and deploy the app in android emulator, or it will not deploy it.
https://github.com/dotnet/roslyn/issues/12132

Here are other ideas to fix it:
https://xamarinhelp.com/debugging-xamarin-android-build-and-deployment-failures/
http://dotnetbyexample.blogspot.hu/2016/02/fix-for-could-not-connect-to-debugger.html

 

🔘 Error: The processor architecture of the project being built “Any CPU” is not supported by the referenced SDK “Microsoft.VCLibs, Version=12.0”. Please consider changing the targeted processor architecture of your project (in Visual Studio this can be done through the Configuration Manager) to one of the architectures supported by the SDK: “x86, x64, ARM”. testSyncfusion.Windows C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets 2049 
Warning: The processor architecture of the project being built “Any CPU” is not supported by the referenced SDK “Microsoft.VCLibs, Version=12.0”. Please consider changing the targeted processor architecture of your project (in Visual Studio this can be done through the Configuration Manager) to one of the architectures supported by the SDK: “x86, x64, ARM”. testSyncfusion.Windows C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets 2049 
Warning: The referenced component ‘Microsoft Visual C++ 2013 Runtime Package for Windows’ could not be found. testSyncfusion.Windows   

1. Make sure that you have installed “Microsoft Visual C++ 2013 Runtime Package for Windows”
2. Got the .Windows project, and right click on its “references” node, and select “add reference”
then go to Tab “Windows 8.1″\Extension, and select (Tick) “Microsoft Visual C++ 2013 Runtime Package for Windows”
3. Go to the solution node in Solution Explorer, right click it and select “Configuration Manager”, then from the list, go to the .Windows project, and select either “x86 or x64”

🔘 Error: clicking HyperLinkLabel asks for Command.cs
Message “IResolver has not been set. Please set it by calling Resolver.SetResolver(resolver) method.” string
System.InvalidOperationException:
HyperLinkLabel “Command.cs”
at XLabs.Ioc.Resolver.get_Instance () [0x0000e] in <filename unknown>:0
at XLabs.Ioc.Resolver.Resolve[T] () [0x00001] in <filename unknown>:0
at XLabs.Forms.Controls.HyperLinkLabel.<.ctor>b__5_0 () [0x00001] in <filename unknown>:0
at Xamarin.Forms.Command+<>c__DisplayClass3_0.<.ctor>b__0 (System.Object o) [0x00000] in C:\BuildAgent3\work\aad494dc9bc9783\Xamarin.Forms.Core\Command.cs:36
at Xamarin.Forms.Command.Execute (System.Object parameter) [0x00000] in C:\BuildAgent3\work\aad494dc9bc9783\Xamarin.Forms.Core\Command.cs:70
at Xamarin.Forms.TapGestureRecognizer.SendTapped (Xamarin.Forms.View sender) [0x00018] in C:\BuildAgent3\work\aad494dc9bc9783\Xamarin.Forms.Core\TapGestureRecognizer.cs:42
at Xamarin.Forms.Platform.Android.TapGestureHandler.OnTap (Int32 count) [0x00028] in C:\BuildAgent3\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\TapGestureHandler.cs:36
at Xamarin.Forms.Platform.Android.InnerGestureListener.Android.Views.GestureDetector.IOnGestureListener.OnSingleTapUp (Android.Views.MotionEvent e) [0x0001c] in C:\BuildAgent3\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\InnerGestureListener.cs:116
at Android.Views.GestureDetector+IOnGestureListenerInvoker.n_OnSingleTapUp_Landroid_view_MotionEvent_ (IntPtr jnienv, IntPtr native__this, IntPtr native_e) [0x00011] in /Users/builder/data/lanes/3053/a94a03b5/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Views.GestureDetector.cs:653
at (wrapper dynamic-method) System.Object:06bb057f-22e4-4a25-a2b3-a455a31fa6b6 (intptr,intptr,intptr)
 This mainly comes because you did not initialize XLabs as they sayed.
🔘 Error: Error Long deployment in the android device
chech the .Droid/Properties/AndroidManifest.xml
maybe the permisions are inserted after the <application>, better to make them before it:
 <manifest xmlns:android=”http://schemas.android.com/apk/res/android”&gt;
<uses-sdk android:minSdkVersion=”15″ />
   <application></application>
<uses-permission android:name=”android.permission.READ_EXTERNAL_STORAGE” />
<uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE” />
 </manifest>
🔘 Error: The “GenerateJavaStubs” task failed unexpectedly.
System.InvalidOperationException: Application cannot have both a type with an [Application] attribute and an [assembly:Application] attribute.
at Xamarin.Android.Tasks.ManifestDocument.CreateApplicationElement(XElement manifest, List`1 subclasses, List`1 selectedWhitelistAssemblies)
at Xamarin.Android.Tasks.ManifestDocument.Merge(List`1 subclasses, List`1 selectedWhitelistAssemblies, Boolean embed, String bundledWearApplicationName, IEnumerable`1 mergedManifestDocuments)
at Xamarin.Android.Tasks.GenerateJavaStubs.Run()
at Xamarin.Android.Tasks.GenerateJavaStubs.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() testSyncfusion.Droid C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 1725 
Application cannot have both a type, it looks that you have two places that have the attrbute Application have been defined, so search in all the solution for “Application”, case sensitive + Full word, and take off the repeted one.
🔘 Error: Type universe cannot resolve assembly: System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. App1.UWP   
Run  the following command in the Package Manager Console  PM> Install-Package Microsoft.NETCore.UniversalWindowsPlatform
Google Play Store Developer Console:
🔘 Error:Your APK’s package name must be in the following format “com.example.myapp”. It may contain letters (a-z), numbers, and underscores (_). It must start with a lowercase character. It must be 150 characters or fewer.
🔘 Warning CS0618 ‘BindableProperty.Create<TDeclarer, TPropertyType>(Expression<Func<TDeclarer, TPropertyType>>, TPropertyType, BindingMode, BindableProperty.ValidateValueDelegate<TPropertyType>, BindableProperty.BindingPropertyChangedDelegate<TPropertyType>, BindableProperty.BindingPropertyChangingDelegate<TPropertyType>, BindableProperty.CoerceValueDelegate<TPropertyType>, BindableProperty.CreateDefaultValueDelegate<TDeclarer, TPropertyType>)’ is obsolete: ‘Generic versions of Create () are no longer supported and deprecated. They will be removed soon.’ Acquaint.XForms D:\4_Prj\Mobile Apps\_Xamarin Apps\Acquaint\src\Acquaint.XForms\Acquaint.XForms\Views\FloatingActionButtonView.cs 17 Active
See the following:
https://forums.xamarin.com/discussion/63268/bindableproperty-pieces-obsoleting
https://developer.xamarin.com/api/member/Xamarin.Forms.BindableProperty.Create/p/System.String/System.Type/System.Type/System.Object/Xamarin.Forms.BindingMode/Xamarin.Forms.BindableProperty+ValidateValueDelegate/Xamarin.Forms.BindableProperty+BindingPropertyChangedDelegate/Xamarin.Forms.BindableProperty+BindingPropertyChangingDelegate/Xamarin.Forms.BindableProperty+CoerceValueDelegate/
🔘 Error:  MakePRI: PRI file is invalid. testSyncfusion.Windows C:\Program Files (x86)\Syncfusion\Essential Studio\14.2.0.26\Xamarin\lib\wp81\Syncfusion.SfShared.WP.pri  
you will need to copy the original .pri file on the problematic .pri file, which you can have either by making a backup before the problem, or re-installing the 3rd party library.

About Reader Man حسين ناجي الصفافير

حسين ناجي الصفافير Hussain Naji Al-Safafeer Info: https://readerman1.wordpress.com/aboutme
This entry was posted in Bugs and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s