How to fix Mono Shared Runtime is not supported when running UI Test
This is a very frustrating issue and I have found lots of unhelpful articles, especially since they all point to Visual Studio 2019.
I get this issue when trying to run a Xamarin.UITest project.
System.Exception : Mono Shared Runtime is not supported. This can be resolved by changing the project configuration or using a Release build.
CSPROJ FILE
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Test|AnyCPU'">
<DebugSymbols>false</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Test</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidManagedSymbols>true</AndroidManagedSymbols>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
<BundleAssemblies>false</BundleAssemblies>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<AndroidSupportedAbis>armeabi-v7a;x86;x86_64;arm64-v8a</AndroidSupportedAbis>
</PropertyGroup>
Properties
1 answer
-
answered 2022-05-04 12:22
ToolmakerSteve
OP (Original Poster aka question-asker) seems to be doing everything right, in specifying the apk.
It appears that a SharedMonoFramework was still on the device, associated with the project's bundle id, from an earlier debug test run.
The app needed to be completely removed from the device.
One of these approaches:
Manually delete app from device.
Command prompt
adb uninstall com.yourcompany.yourapp
(the bundle id).Factory reset the device.
do you know?
how many words do you know
See also questions close to this topic
-
Change item control property of checked listview item Xamarin.Forms
Hy, I am trying to show a comment input if the item checkbox is checked and hide it else, i have this XAML
<ListView ItemsSource="{Binding TaskItems}" x:Name="TasksItems" HasUnevenRows="True" VerticalScrollBarVisibility="Default" SelectionMode="None"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <StackLayout IsVisible="True" Orientation="Vertical"> <Grid BackgroundColor="White"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"></ColumnDefinition> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="auto" /> </Grid.RowDefinitions> <StackLayout Grid.Column="0" Grid.Row="0"> <input:CheckBox Type="Box" IsChecked="{Binding TaskChecked , Mode=TwoWay}"/> </StackLayout> <StackLayout Grid.Column="0" Grid.Row="1" IsVisible="{Binding CommentRequired}"> <Entry BackgroundColor="White" PlaceholderColor="Black" HeightRequest="40" TextColor="Black"/> </StackLayout> </Grid> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate>
and i have this c# code to read the items from database
public class TaskData { public bool TaskChecked { get; set; } public bool CommentRequired { get; set; } } public partial class HomePage : ContentPage { public HomePage() { ObservableCollection<TaskData> TaskItems { get; set; } ObservableCollection<TaskData> TasksList; TaskItems = new ObservableCollection<TaskData>(); //Loop the tasks from database result While... TaskItems.Add(new TaskData { TaskChecked = false, CommentRequired = false, }); //End Loop TasksListView.ItemsSource = TaskItems; } }
Now i need to add a "CheckChanged" event to show the comment Entry (IsVisible="True") when the user check the checkbox of the targed listview item
Thanks
-
Uploading Image files from Xamarin App to Gallery and Azure
I am working on a development (Android, IOS) that requires uploading Images files to an Azure Storage, this images can be taken from the gallery or with the device's camera.
For this I have implemented the following:
-Image Capture (I'm using Xamarin.Essentials.CapturePhotoAsync()) (Solved) -Images from Gallery (I'm using Xamarin.Essentials.PickPhotoAsync()) (Solved)
Both actions are stored in a List that will finally uploaded to the azure storage.
First question: Is this the best "approach" to upload files to storage? Is there a better practice than storing all this information in a list and finally uploading it?
In addition to this, I have a new requirement and that is that the captured images can be stored in the device's gallery. Hence my second question....
Which is the best way to get it to work on both Android and IOS? Tried some methods, but not everything works properly...
The libraries that can possibly solve this are a bit outdated or don't work in all cases....
(Xam.Plugin.Media) Have some issues on resent Android devices (Xamarin.MediaGallery) works great on Android but on IOS it's another story 😕 Dependency Services: it is the most successful and a different angle than nugets but... it currently has some things deprecated like storage routes in Android for save in Gallery....
I would appreciate your recommendations.
-
Put an image from camera with migradoc or pdfsharp with xamarin forms
I have a problem that I can't put an image from the camera to the pdf. It put the same error
"Image could not read"
. How can I do it? This is the path they gave me when I take a photo ="/storage/emulated/0/Android/data/com.companyname.atecresacalculator/files/Pictures/fotoparapdf_12.jpg"
code from CompartirInformacion(SharedInformation):
namespace AtecresaCalculator.Service { public class CompartirInformacion { public static string x; public static string y; } }
where I added into the pdf:
Row row = table.AddRow(); table.Rows.HeightRule = RowHeightRule.Auto; row.Cells[0].AddParagraph(text); row.Cells[0].VerticalAlignment = VerticalAlignment.Center; row.Cells[1].AddParagraph(texto); row.Cells[1].AddImage(FromFile(CompartirInformacion.y)); row.Cells[1].VerticalAlignment = VerticalAlignment.Center;
Clicked to take the photo:
private async void sacarFoto_Clicked(object sender, EventArgs e) { await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { await DisplayAlert("Error en la cámara", "Activa los permisos para usar cámara", "Ok"); return; } var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions { PhotoSize = Plugin.Media.Abstractions.PhotoSize.Small, Name = "fotoparapdf.jpg", CompressionQuality = 100, DefaultCamera = Plugin.Media.Abstractions.CameraDevice.Rear, }); if (file == null) return; await DisplayAlert("Ruta de la foto", file.Path, "Ok"); CompartirInformacion.y = file.Path; }
-
Linker errors in Xamarin Forms iOS
I am getting below linker errors upon build in an Xamrain Forms iOS project. I have tried from both a Visual Studio for Mac and from Visual Studio Windows paired with a Mac.
I have referenced as many Xamarin.Firebase.iOS.* assemblies as I can see as relevant but no luck.
What am I doing wrong?
Thanks
Regards
Native linking failed, undefined symbol: _GULLogWarning. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. Native linking failed, undefined symbol: _pb_encode_varint. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. Native linking failed, undefined Objective-C class: GULNetwork. The symbol '_OBJC_CLASS_$_GULNetwork' could not be found in any of the libraries or frameworks linked with your application. Native linking failed, undefined symbol: _GULLogBasic. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. ] in GoogleAppMeasurement(APMMeasurement.o) Native linking failed, undefined symbol: _kGULNetworkHTTPStatusOK. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. Native linking failed, undefined symbol: _pb_encode_submessage. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. Native linking failed, undefined symbol: _kGULNetworkHTTPStatusCodeNotFound. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. Native linking failed, undefined symbol: _pb_encode_string. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. Native linking failed, undefined symbol: _kGULNetworkHTTPStatusCodeCannotAcceptTraffic. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. Native linking failed, undefined Objective-C class: GULAppEnvironmentUtil. The symbol '_OBJC_CLASS_$_GULAppEnvironmentUtil' could not be found in any of the libraries or frameworks linked with your application. Native linking failed, undefined symbol: _GULSetLoggerLevel. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. Native linking failed, undefined symbol: _pb_ostream_from_buffer. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. ] in GoogleAppMeasurement(APMMeasurement.o) Native linking failed, undefined Objective-C class: GULMutableDictionary. The symbol '_OBJC_CLASS_$_GULMutableDictionary' could not be found in any of the libraries or frameworks linked with your application. Native linking failed, undefined Objective-C class: GULAppDelegateSwizzler. The symbol '_OBJC_CLASS_$_GULAppDelegateSwizzler' could not be found in any of the libraries or frameworks linked with your application. Native linking failed, undefined symbol: _pb_istream_from_buffer. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. Native linking failed, undefined symbol: _pb_read. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. Native linking failed, undefined symbol: _kGULNetworkHTTPStatusCodeUnavailable. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. ] in GoogleAppMeasurement(APMMeasurement.o) Native linking failed, undefined Objective-C class: GULSwizzler. The symbol '_OBJC_CLASS_$_GULSwizzler' could not be found in any of the libraries or frameworks linked with your application. Native linking failed, undefined symbol: _pb_decode_varint. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. Native linking failed, undefined symbol: _GULIsLoggableLevel. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. Native linking failed, undefined symbol: _pb_encode. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. Native linking failed. Please review the build log and the user flags provided to gcc: -ObjC -lc++ -lsqlite3 -lz Native linking failed, undefined symbol: _pb_decode. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. Native linking failed, undefined symbol: _GULLog. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. Native linking failed, undefined symbol: _pb_encode_tag_for_field. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. Native linking failed, undefined symbol: _kGULNetworkHTTPStatusNoContent. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. ] in GoogleAppMeasurement(APMMeasurement.o) linker command failed with exit code 1 (use -v to see invocation) Native linking failed, undefined symbol: _GULLogInfo. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. Native linking failed, undefined symbol: _kGULNetworkHTTPStatusCodeNotModified. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.
-
Porting Xamarin tutorial over to .NET MAUI
For my first ever mobile app project (which will eventually become an actual commercial project), I would like to try out .NET MAUI. Unfortunately since it's still in pre-release, there is scarce documentation and no tutorial projects for it. I did find the Xamarin tutorial here:
https://dotnet.microsoft.com/en-us/learn/xamarin/hello-world-tutorial/intro
... but I don't think it's compatible with .NET MAUI.
Are there any other places where a newbie mobile developer who knows Visual Studio and C# can see an example app and be able to learn through creating an app on the level of, say, the Contoso University web app I went through to learn ASP.NET Core with data model? Can a Xamarin tutorial be tweaked to work with .NET MAUI? If so, I would be happy to help with that process. Now that I think about it, since I developed my web site based on the Contoso model, maybe I could help create a mobile app in .NET MAUI for that Contoso project? Anyone at Microsoft interested?
-
Cant create an alarm in Xamerin Android C#
Copied my teacher's simplified code in order to see if the code i wrote was wrong or somthing yet even her's isnt working. Here is it:
private void BtnAlarm_Click(object sender, EventArgs e) { Intent intentAlarm = new Intent(this, typeof(AlarmReceiver)); // #2 - Pending intent - > Broadcast PendingIntent pendingIntent = PendingIntent.GetBroadcast(Application.Context, 1, intentAlarm, 0); // #3 - Set Alarm Manager AlarmManager alarmManager = (AlarmManager)GetSystemService(AlarmService); //30s alarmManager.SetExactAndAllowWhileIdle(AlarmType.ElapsedRealtimeWakeup, SystemClock.ElapsedRealtime() + 30 * 1000, pendingIntent); }
The debugger wont run onto this activity:
public class AlarmReceiver : BroadcastReceiver { public override void OnReceive(Context context, Intent intent) { Toast.MakeText(context, "Received intent!", ToastLength.Short).Show(); } }
Just to be clear, while running her app the alarm was working.
-
Azure B2C broken when explicitly-declared value for android:exported is used
My Xamarin.Forms application uses Azure AD B2C for authentication. Currently, I have to use Android 12 instead of Android 10. According to the documentation, it required a certain change:
Warning: If an activity, service, or broadcast receiver uses intent filters and doesn't have an explicitly-declared value for android:exported, your app can't be installed on a device that runs Android 12 or higher.
(https://developer.android.com/about/versions/12/behavior-changes-12#security)
This is my code from MsalActivity.cs:
namespace UserDetailsClient.Droid { [Activity(Exported = false)] [IntentFilter(new[] { Intent.ActionView }, Categories = new[] { Intent.CategoryBrowsable, Intent.CategoryDefault }, DataHost = "auth", DataScheme = "msal5c32fe58-4a77-49ea-8b5d-010c4a684e4f")] public class MsalActivity : BrowserTabActivity { } }
After I added (Exported = false), I was able to deploy and run the app. But now I am not able to log in. The login screen does show up. And the user can enter the credentials, but after submitting, we get stuck on this screen:
Nothing new appears in the output window. How can this be diagnosed and fixed?
-
Convert a short DateTime string with date and time to DateTime
Having trouble with my Android project here trying to convert a string of DateTime into an actual DateTime object. here's the code I wrote:
string strDateTime = reminder.Date + " " + ((ReminderByTime)reminder).ReminderTime; userDateTime = DateTime.ParseExact(strDateTime, "MM/dd/yyyy HH/mm", null);
While running the problem I've checked the values and they do coordinate:
How can I fix this?
-
Timed out waiting for result of ClearAppData2
I'm new to UI Tests for Xamarin. I thought it will work out of the box. It doesn't.
If I run the test on my external device via USB. Everything works just fine.
If I run any test using emulator (adb) I get an error: "System.Exception : Timed out waiting for result of ClearAppData2"
If I go to logs, I can see that adb is denied an access to some files.
Ok. I used "adb root".
Now it is showing this
10-04-2022 21:16:55.863 -04:00 - 45356 - AdbArguments: '-s emulator-5554 shell ls "/data/data/com.company.product.test/files/calabash_finished.out"'. 10-04-2022 21:16:55.901 -04:00 - 45393 - Finished with exit code 1 in 37 ms. ls: /data/data/com.company.product.test/files/calabash_finished.out: No such file or directory
The log shows this message for several files.
Why every time I deal with "outOfTheBox" Microsoft solutions they do not work? Or maybe it's Visual Studio 2022 problem?
I tried to reinstall everything to no avail.
-
Xamarin UITest | adb cmd to open mobile phone Internal storage via mobile screen (not through adb pull command and pull the data )
Our application is built on xamarin form and I am performing xamarin UITest to automate the android native app.
Scenario: During the validation I have to navigate to Phone's Internal Storage location where I have to open a folder in it(created before this step) -> open sysId.txt file -> validate the content of the file.
My Approach: I tried many ways to find a proper command which opens the internal storage via mobile screen but i couldn't find any solution other than using mobile screen coordinates(PFB)
Below commands are used to navigate from home screen to my txt file location (these steps would work only on MotoG8_Plus):
To open Files folder adb shell monkey -p com.google.android.apps.nbu.files -v 10
Swipe Down in Files Folder : adb shell input swipe 500 1000 300 300
Tap on Internal Storage : adb shell input tap 650 1800
Tap on iSpiro Folder : adb shell input tap 1000 1150
Tap on sysId.txt : adb shell input tap 400 400
Tap on HTML viewer : adb shell input tap 300 2000
Note: Above cmd's are working only in Motog8_Plus mobile device as the internal storage path and tap & click coordinates are specific to this device but I'm looking for a generic solution to Open Internal storage folder(via mobile screen) and click on folders by name(e.g click xyz folder using adb command by its name xyz)
Thank you for the help in advance!