Exception: Only the original thread that created a view hierarchy can touch its viewsJanuary 13, 2015, 6:03 am Show
The code below works on Windows Phone but when running on Android I am getting the following exception : android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. public ButtonLoggerPage() { // Create the Button and attach Clicked handler. Button button = new Button { Text = "Log the Click Time" }; button.Clicked += OnButtonClicked; opusClient.LoginCheckCompleted += OpenReadLogincheck; this.Padding = new Thickness(5, Device.OnPlatform(20, 0, 0), 5, 0); tbSyncItemLbl = new Label { }; // Assemble the page. this.Content = new StackLayout { Children = { button,new ScrollView { VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Gray, Content = loggerLayout} } }; } void OnButtonClicked(object sender, EventArgs args) { loginCheck(); } public void loginCheck() { try { client.LoginCheckAsync(username, password); } catch (Exception e) { receiveErrors = 22; } } void OpenReadLogincheck(Object sender, LoginCheckCompletedEventArgs e) { if (e.Result != null) { LoginStatus = e.Result.Value; if (e.Result == 1) { addMessage("Login Succeeded", Direction.Download); }} Only the original thread that created a view hierarchy can touch its views.February 20, 2019, 10:53 am Hi there! First of all, my english is not very well, so please be patient to read my question slowly. Well, as you can see on the tittle, I got a problem about threads. I'm using a Listview and trying to binding the ItemSource from a viewmodel loaded with data (I'm trying to do something like a timeline using facebook or instagram as example). The case is... when I try to use "Binding" I got this Error Message: "Unhandled Exception: Yeah, I know this question has been answered in another threads in the forum with the following code: But that line is the one that makes de app get into a Break Mode. So... any idea? Thanks for read. Android.Util.AndroidRunTimeException:Only the original thread created a view hierarchySeptember 26, 2017, 7:44 am It Seems to happen more often on Go Back or going back using Logout button which has almost similar implementations, and If I try to login again. I tried to find solution for this but this unexpected error has very less talk.. however I have found a relevant post where it was closed as a xamarin forms problem. Please any help in this matter will be appreciated. Really stuck on that. Xamarin Essentials- IOS not restore the preferences if the app ruining in background is kiiledApril 12, 2019, 1:01 am I used Preferences API for saving the user credentials on both iOS and Android. It worked correctly but after updating Xamarin Essentials to the version 1.1.0, the user credentials can not be restored on the iOS device. If I close the app (but it is still running in the background ) the user credentials are restored
correctly. IDE: Visual Studio 8.0.2 (.netstandard 2.0) All references broken after moving project to another computerJune 28, 2018, 2:35 pm After moving computers, all the references are missing. I tried using NuGet package restore but it just said 0 packages to restore. I tried uninstalling and reinstalling all the packages. I tried updating the packages. Even packages that weren't installed before show up with the yellow triangle after being installed. I also tried manually adding the references by pointing to the .dll files but the references still show up with yellow triangles. Please help! Thank you in advance. Touch event on a control under a Transparent GridApril 14, 2019, 11:57 pm Hi all, I have a Relative layout like this.
My issue is I want to zoom, drag the google map. But the Grid has a bigger z-index (althought it's Transparent) so I could not touch any event to my google map. If I set InputTransparent="True" to grid. I can touch the google map but I cannot touch to my control box... Do you have any suggestion with that kind of layout? Thank you so much, How I can enable auto login in UIWEBVIEWApril 13, 2019, 8:32 am hello, and I went to enable auto login is user make a success login i.e " save login information "public void prepare_webview() { main_web_view.ScrollView.Bounces = false; //Disable Zoom main_web_view.MultipleTouchEnabled = false; main_web_view.ScalesPageToFit = false; //Set User Agent var dictionary = NSDictionary.FromObjectsAndKeys(new[] { "Android" }, new[] { "UserAgent" }); NSUserDefaults.StandardUserDefaults.RegisterDefaults(dictionary); // Enable Cache NSUrlCache.SharedCache = new NSUrlCache(4 * 1024 * 1024, 20 * 1024 * 1024, "webcache"); NSHttpCookieStorage.SharedStorage.AcceptPolicy = NSHttpCookieAcceptPolicy.Always; // Load Site main_web_view.LoadRequest(new NSUrlRequest(new NSUrl(url)));}Nlog configuration file not getting loadedApril 3, 2019, 3:56 am Below stmt I tried passing file name in all ways i could think of. Also can anyone explain me does the above statement is used to log error in that file or that its just rules that are to be followed in the file? Do i have to create a new file where everything gets logged in? Thanks, Can someone from Xamarin please, please take a look at the developing for the Apple Watch?October 18, 2018, 1:34 am I hate to be so negative but, having spent literally weeks trying to get a Xamarin application to deploy to a physical Apple Watch, I believe that this is not currently possible. To speak even more frankly, I think this 'feature' should either be removed from Xamarin or properly supported. For over a year, I have been working around various Xamarin foibles on a new tech startup project that is literally the difference between my having a future and not. So, when I chose to put my faith in Xamarin, the stakes could not have been higher. Initially, I paid the full whack for a Xamarin licence. Both before and after Microsoft bought Xamarin, I have generally been satisfied with the support I have received, both here on this forum and from Xamarin. But the Apple Watch support is a different story. To be fair, I have received help from various people with this, but the fact remains that here I am, six months after first looking into the Apple Watch on Xamarin, with my whole project and future dead in the water. I have followed every single guide and troubleshooter out there. I just cannot get a Xamarin application to go on to a physical Apple Watch. I managed it just once. I even hit a breakpoint in the debugger on the PC! I thought, "Great! Now I can begin work tomorrow morning." The following morning, without touching a line of code or a single setting, the whole thing was broken again. And I have never got it going since that day, which was about two months ago now. Generally, I remain impressed by Xamarin, but , please, please, please can someone take a look at the deployment of code on to a physical Apple Watch? It is unusable as it stands. And therefore, as it stands, my new business doesn't have a chance and I am forced to admit that my time might have been better spent simply learning to use XCode on the Mac. Yours desperately - A Loyal Xamarin Developer An error occurred trying to load the page. Index was outside the bounds of the array.April 12, 2019, 12:09 am I'm building a mobile application using Xamarin Form.When I tried to open AndroidManifest.xml in Visual Studio 2019 Community by Right Click -> Xamarin.Android Project -> Properties -> Android Manifest , I'm getting following error, "An error occurred trying to load the page. Index was outside the bounds of the array." But the application is working perfectly, just does not show the Android Manifest in properties. I have try recreate the Android Manifest again and replace the old Manifest in Xamarin.Android but it still does not resolve the problem. I have delete bin and obj file of Xamarin.Android but still problem persist. I have create another new Xamarin Form and try to read the AndroidManifest.xml from properties and I can read it. But It just does not show in Xamarin Form my project1. I have check the Xamarin Log in Visual studio by going too Help -> Xamarin -> Open Logs . It do show some error log. Can anyone help me regrading this problem. I have attached the Xamarin Log regarding the problem and include the Android Manifest Android Manifest <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0.0" package="com.companyname.VMS.ResidentMobileApp" android:installLocation="preferExternal"> <application> <provider android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data> </provider> </application> <uses-sdk android:minSdkVersion="18" android:targetSdkVersion="26" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.CAMERA" /> <application android:label="VMS.ResidentMobileApp.Android"></application> </manifest> Change a source of image in a controltemplateApril 1, 2019, 12:53 am Hi everyone, I'm starting with Xamarin and I didn't find how to change a source of image in controltemplate. I want to change the image when the Wi-Fi state change. <ControlTemplate x:Key="State"> <Grid ColumnSpacing="0"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="11*"/> </Grid.ColumnDefinitions> <BoxView Grid.Column="0" Style="{DynamicResource boxviewStyle}"/> <ContentPresenter Grid.Column="1" /> <Grid Grid.Column="0"> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="*"/> <RowDefinition Height="*"/> <RowDefinition Height="*"/> <RowDefinition Height="*"/> <RowDefinition Height="*"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Button x:Name="ButtonHome" Grid.Column="0" Grid.Row="0" Style="{DynamicResource buttonStyle}" Image="home_48x46.png" Clicked="onClickedButtonHome"/> <Label x:Name="LabelBattery" Grid.Column="0" Grid.Row="1" Style="{DynamicResource labelStyle}" TextColor="White" Text="100 %" VerticalOptions="Center" HorizontalOptions="Start" Margin="5"/> <Image x:Name="Battery" Grid.Column="0" Grid.Row="1" Source="battery_icon_100_40px.png" VerticalOptions="Center" HorizontalOptions="End" Margin="5"/> <Label x:Name="LabelTime" Grid.Column="0" Grid.Row="2" Style="{DynamicResource labelStyle}" HorizontalOptions="Center" Text="08:35"/> <Button x:Name="ButtonGPS" Grid.Column="0" Grid.Row="3" Style="{DynamicResource buttonStyle}" Image="gps_icon_pos_70px.png" Clicked="onClickedButtonGPS"/> <Image x:Name="ImageWIFI" Grid.Column="0" Grid.Row="4" Source="wifi_off_70px.png" HorizontalOptions="Center"/> <Button x:Name="ButtonMore" Grid.Column="0" Grid.Row="6" Style="{DynamicResource buttonStyle}" Image="trois_points_70px.png" Clicked="onClickedButtonMore"/> </Grid> </Grid> </ControlTemplate>`Thank you very much, Is there a tool that converts UWP/Windows 10 XAML to Xamarin Forms XAML?April 13, 2019, 6:21 am I have developed some apps that run on UWP. Now I want to convert them to Xamarin Forms since Windows 10 mobile is pretty much dead. Is there a tool that can convert UWP XAML to Xamarin Forms XAML? Incompatible iOS versions 12.4 12.8April 13, 2019, 1:08 am Ive got VS 2017 (15.9.11) running on my win 10 pc and have been happily connecting with a mac which has VS Is the only answer to reinstall VS for Mac ? If so how to prevent it updating to 12.8? Is the only answer to keep the two separate and just transfer the project when I want to build for iOS? Any suggestions gratefully
received ! Set a Picker.SelectedItem on page startupApril 12, 2019, 3:11 am I have this piece of code <Picker x:Name="CategoryPicker" ItemsSource="{Binding Categories, Mode=TwoWay}" SelectedItem="{Binding Path= RequestItem.Category, Mode=TwoWay}" HorizontalOptions="FillAndExpand" Title="Escolha uma Categoria" SelectedIndexChanged="OnSelectedIndexChanged" ItemDisplayBinding="{Binding Name}" Margin="10,20,10,0">I'm saving an item, and when I save it, it goes to a list of items... If I want to change one of those items, I need to set the picker to the value stored in RequestItem.Category... I've also tryed to do this on my Page constructor with this None of those seems to work... What am I doing wrong? Xamarin Android support.V7 and V4 Breaking the VS2017 design view in V28.xxApril 12, 2019, 1:23 pm Hi All I updated my App to V28, now the design view is full of red error patches. I tried to delete an reinstall packages to no result. I tried a basic template with V27 and it works, and design view works V28 appears to have broken up the few V7 and v4 support nugets into multiple inter dependent nugets which have to be uninstalled inthe right sequence, so now I am going back and forth trying to revert to v27 Please fix this Cheers App crashed on clicking entry fielding in android oreo 8.1April 10, 2019, 10:12 pm [0:] [Info][MenuSelectionPageViewModel] Closed System.NullReferenceException: Object reference not set to an instance of an object. Mono.AndroidTools.SdkNotSupportedException when trying to deploy to emulatorApril 7, 2019, 6:50 pm I just installed VS2019 Mac. I have a Xamarin.Forms project that runs under Android. I right-click and select Options, and have the following options set:
I select the Android project and this emulator that got created for me during VS install: Android_Accelerated_Nougat (API 25) and select the Play icon to deploy and debug the application on this emulator. During deploy, I end up with the exception below. Any ideas on how best to debug this. Any good, basic reference links would be welcome too, as this is the first time we're targeting Android. /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(615,2): error ADB0000: Deployment failed /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(615,2): error ADB0000: Xamarin.AndroidTools.AndroidDeploymentException: SdkNotSupportedByDevice ---> Mono.AndroidTools.SdkNotSupportedException: The device does not support the minimum SDK level specified in the manifest. /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(615,2): error ADB0000: at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess (System.String output, System.String packageName) [0x00095] in /Users/builder/jenkins/workspace/monodroid-multibranch_d16-0-ROFMKET2X57L6OM33VV4CLSC53EGKYMXL7RAG3T2HOJWPTP3PQCA/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Internal/AdbOutputParsing.cs:329 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(615,2): error ADB0000: at Mono.AndroidTools.AndroidDevice+<>c__DisplayClass95_0.<InstallPackage>b__0 (System.Threading.Tasks.Task`1[TResult] t) [0x00016] in /Users/builder/jenkins/workspace/monodroid-multibranch_d16-0-ROFMKET2X57L6OM33VV4CLSC53EGKYMXL7RAG3T2HOJWPTP3PQCA/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/AndroidDevice.cs:753 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(615,2): error ADB0000: at System.Threading.Tasks.ContinuationTaskFromResultTask`1[TAntecedentResult].InnerInvoke () [0x00024] in <b4d1a66727f44ba888b54966284fabb4>:0 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(615,2): error ADB0000: at System.Threading.Tasks.Task.Execute () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-08/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2343 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(615,2): error ADB0000: --- End of inner exception stack trace --- /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(615,2): error ADB0000: at Xamarin.AndroidTools.AndroidDeploySession.InstallPackage () [0x0036a] in /Users/builder/jenkins/workspace/monodroid-multibranch_d16-0-ROFMKET2X57L6OM33VV4CLSC53EGKYMXL7RAG3T2HOJWPTP3PQCA/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:418 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(615,2): error ADB0000: at Xamarin.AndroidTools.AndroidDeploySession.RunAsync (System.Threading.CancellationToken token) [0x003ae] in /Users/builder/jenkins/workspace/monodroid-multibranch_d16-0-ROFMKET2X57L6OM33VV4CLSC53EGKYMXL7RAG3T2HOJWPTP3PQCA/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:216 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(615,2): error ADB0000: at Xamarin.AndroidTools.AndroidDeploySession.RunLoggedAsync (System.Threading.CancellationToken token) [0x0002f] in /Users/builder/jenkins/workspace/monodroid-multibranch_d16-0-ROFMKET2X57L6OM33VV4CLSC53EGKYMXL7RAG3T2HOJWPTP3PQCA/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:118 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(615,2): error ADB0040: The device does not support the minimum SDK level specified in the manifest. /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(615,2): error ADB0040: at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess (System.String output, System.String packageName) [0x00095] in /Users/builder/jenkins/workspace/monodroid-multibranch_d16-0-ROFMKET2X57L6OM33VV4CLSC53EGKYMXL7RAG3T2HOJWPTP3PQCA/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Internal/AdbOutputParsing.cs:329 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(615,2): error ADB0040: at Mono.AndroidTools.AndroidDevice+<>c__DisplayClass95_0.<InstallPackage>b__0 (System.Threading.Tasks.Task`1[TResult] t) [0x00016] in /Users/builder/jenkins/workspace/monodroid-multibranch_d16-0-ROFMKET2X57L6OM33VV4CLSC53EGKYMXL7RAG3T2HOJWPTP3PQCA/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/AndroidDevice.cs:753 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(615,2): error ADB0040: at System.Threading.Tasks.ContinuationTaskFromResultTask`1[TAntecedentResult].InnerInvoke () [0x00024] in <b4d1a66727f44ba888b54966284fabb4>:0 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(615,2): error ADB0040: at System.Threading.Tasks.Task.Execute () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-08/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2343Zip Extraction code not working for Android in xamarin formsApril 11, 2019, 5:11 am I am using below code for extraction in xamarin forms using (ZipArchive archive = ZipFile.OpenRead("Zip file path")) { foreach (ZipArchiveEntry entry in archive.Entries) { var pathToInstall = Path.GetDirectoryName(Path.Combine("Extract Directory", entry.FullName)); if (!Directory.Exists(pathToInstall)) { Directory.CreateDirectory(pathToInstall); } using (var entryStream = entry.Open()) { entry.ExtractToFile(Path.Combine("Extract Directory", entry.FullName), true); } } }Here** entry.ExtractToFile(Path.Combine("Extract Directory", entry.FullName), true)** is throwing below exception: {System.IO.IOException: Invalid parameter at System.IO.File.SetLastWriteTime (System.String path, System.DateTime lastWriteTime) [0x0002a] in <d4a23bbd2f544c30a48c44dd622ce09f>:0 at System.IO.Compression.ZipFileExtensions.ExtractToFile (System.IO.Compression.ZipArchiveEntry source, System.String destinationFileName, System.Boolean overwrite) [0x00067] in <1a0f8b38772b44ca85cc92de9ff0e2e6>:0 at SharedProject.Infrastructures.Protocols.Smb.PackageManager.Extract (System.String zipPackagePath) [0x00059] in D:\VS2017\DocSyncMobile\Xamarin Forms\DocSync\DocSync\DocSync\Infrastructures\Protocols\Smb\PackageManager.cs:41However this code is working fine in windows. Xamarin.Forms XAML RelativeLayout can not scrollApril 10, 2019, 11:48 pm Hi guys, i have a piece of code like this and i want to create a UI that looks like this image here. But it does not works, i'm not sure where did i go wrong. please help me. Xamarin.Forms XAML Share and PreviewApril 14, 2019, 2:05 am Hello, You can write the XAML/CSS and preview it on the Android app, live, without recompiling. (iOS app will be available soon) Please feel free to use it, and send feedback to us! |