Xamarin Forms Xaml Android Preview error - visual-studio

At some point in development the Xaml previewer stopped working for my Xamarin forms app, the app runs fine it just slows down visual testing.
I'm not quite sure how to diagnose the issue as I'm not sure where it's coming from. Image attached so what I'm working with. Cleared the /bin /obj and other caches, installed latest updates.
The full error is,
System.TypeInitializationException was thrown. The type initializer
for 'Kwike.App' threw an exception.
at at offset 51 in file:line:column :0:0
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj,
System.Object[] parameters) in :0
iOS works fine. It could have something to do with a particular style or resource but I'm not sure. Is there a way to debug more info out of this. Also, this might sound silly but I'm not sure what Kwike.App is that is the name of the app but I cannot locate this file.
It's project specific as the previewer works on a new forms project.

Related

UWP App is crashing on startup but only after installing the app

I am having a problem with a UWP app that is crashing on startup. It crashes only once after the app is installed, either via Debug button on VS2019/2022 or via the Release bundle install package.
If I launch it a second time after the installation, the app won't crash anymore.
We don't know why that is going on and we would like to fix this crash so that the app doesn't crash after installing it.
The crash exception is the following:
Unhandled exception at 0x7726BF4B (MrmCoreR.dll) in AppName_UWP.exe: 0xC0000005: Access violation reading location 0x02000087.
I have uploaded an app memory dump as well as a screenshot showing everything that I have tried to fix this error until now - you can download it here
In a nutshell, we have tried:
Debugging in "Native Only"
Debugging in "Mixed"
Removing references to other libraries that could have caused the exception
Commenting references to Win UI
Change how XAML resources are added in App.xaml
Does anyone have an idea of what this could be and how to fix it?

Google Sign-In for iOS using Xamarin throws exception logs point to podfile

Trying to implement the Google Sign-In for IOS in a Xamarin project. Right on the Google page where it generates your GoogleService-Info.plist file, it says, "Insure you have CocoaPods installed and configured for your project. In you Podfile, include the following: pod 'Google/SignIn'".
And sure enough, the log on the Mac shows a similar error when going through the initial configuration.
But, I can't find anything that really tells me how to add a "Podfile" to a Xamarin IOS project (from within Visual Studio 2017, running on Windows 10).
So, when it comes time to actually click the Sign-In with Google button, in an IOS 10.3 IPhone 6 simulator, it throws an exception,
"Foundation.MonoTouchException: Objective-C exception thrown. Name:
NSInvalidArgumentException Reason: -[__NSCFString
countByEnumeratingWithState:objects:count:]: unrecognized selector
sent to instance 0x608000047200".
I can only hope it is really because of a missing component that the Podfile is supposed to resolve.
Saw a sample from a year ago that supposedly worked, but with what seems to be current right now, I can't get it to.
Update:
The sample I am trying to use, creates a custom class for the View so it can implement a custom Renderer, and a custom class for the page, again, so it can implement a custom Renderer. The View Renderer simply does:
signInButton = new SignInButton();
signInButton.Style = ButtonStyle.Wide;
signInButton.ColorScheme = ButtonColorScheme.Dark;
SetNativeControl(signInButton);
The Google button shows up, but when you click, you get the exception listed above.
A recent update to Xamarin required an update to XCode. With the update to XCode 9,the problem went away, and Google authorization is working.

Xamarin Forms 2.3.3.175 Scroll View Layer exceeds max. dimensions supported by the GPU

After upgrading Forms from 2.3.2.127 my app began to crash. After downgrading the Forms to 2.3.2.127 the issue went away, and I did try 2.3.3.193 and the issue happens there as well.
I have included a link to a PCL test app that will recreate this issue if anyone has any idea as to what I could be doing wrong or some type of workaround that would be great.
Once you start the app you will notice the tab page shows up oddly, if you navigate to the menu and select any of the items the app will crash when it attempts to load that page and render the scroll view. You will also see this exception thrown java.lang.IllegalStateException: Unable to create layer for ScrollViewRenderer
PCL test app zip

Trouble running cross platform UITests on Xamarin.iOS

I am having a few issues running my Xamarin UItests on iOS side of a shared application. The tests run no problem on Android, but I am getting a
System.Exception when I try to run them on iOS.
SetUp : System.Exception : This app bundle is not valid for running on
a simulator. To fix this issue please ensure that your target device
is a simulator.To run against an installed app on a physical device
you can useInstalledApp("ie.eoin.myapp")
I try run the tests on the simulator as well as on a real device with the same exception. Below is the start of the stack trace.
Xamarin.UITest.iOS.iOSAppLauncher.LaunchAppLocal(Xamarin.UITest.Configurati`enter code here`on.IiOSAppConfiguration appConfiguration, Xamarin.UITest.Shared.Http.HttpClient httpClient, System.Boolean clearAppData) [0x0008a] in <b034e37336b84a95a2482a0c5f0be621>:0
at Xamarin.UITest.iOS.iOSAppLauncher.LaunchApp (Xamarin.UITest.Configuration.IiOSAppConfiguration appConfiguration, Xamarin.UITest.Shared.Http.HttpClient httpClient, Xamarin.UITest.TestCloud.TestCloudiOSAppConfiguration testCloudAppConfiguration, Xamarin.UITest.Shared.Http.HttpClient testCloudWsClient, Xamarin.UITest.Shared.Http.HttpClient xtcServicesClient, System.Boolean testCloudUseDeviceAgent) [0x0007a] in <b034e37336b84a95a2482a0c5f0be621>:0
at Xamarin.UITest.iOS.iOSApp..ctor (Xamarin.UITest.Configuration.IiOSAppConfiguration appConfiguration) [0x00302] in <b034e37336b84a95a2482a0c5f0be621>:0
at Xamarin.UITest.Configuration.iOSAppConfigurator.StartApp (Xamarin.UITest.Configuration.AppDataMode appDataMode) [0x00017] in <b034e37336b84a95a2482a0c5f0be621>:0
at Shared.UITest.AppInitializer.StartApp () [0x00036] in /Users/eoinahern/Documents/xamarin_projs/HomeApp.Mobile/Shared/Shared.UITests/AppInitializer.cs:23
at Shared.UITest.Common.SetUp () [0x00002] in /Users/eoinahern/Documents/xamarin_projs/HomeApp.Mobile/Shared/Shared.UITests/Common.cs:17
at Shared.UITests.MapScreensTests.SetUp () [0x00002] in /Users/eoinahern/Documents/xamarin_projs/HomeApp.Mobile/Shared/Shared.UITests/MapScreens/MapScreensTests.cs:16
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in /private/tmp/source-mono-4.6.0/bockbuild-mono-4.6.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
In my startApp() method in the AppInitializer class, the path is pointing to the correct .app file in bin directory.
public static IApp StartApp()
{
switch (TestEnvironment.Platform)
{
case TestPlatform.Local:
#if __IOS__
platform = Platform.iOS;
return ConfigureApp
.iOS
.AppBundle(GetLocalIOSTestAppPath()) .StartApp(Xamarin.UITest.Configuration.AppDataMode.Clear) as IApp;
#endif
}
I am not sure why the tests wont run. I tried changing to an actual device. Also, the .app file has what looks like the symbol from a stop sign as its icon. Not sure what this means. I'll check out what that means next, but for now I am stumped. Any help is appreciated. seriously stuck here.
Have you solved this issue?
just as assumption: maybe you need to use .ipa file instead of .app
Hopefully you've solved this already, but for anyone else who finds this question:
iOS is super picky about what the configuration is for real devices vs simulators. This bit of the docs should help you out, but in summary:
for real devices, your app configuration should look like this:
IApp app = ConfigureApp
.iOS
.InstalledApp("your.app.name")
.StartApp();
If you use the Installed App, you do have to, yk, install the app on the device before attempting to run the tests.
for simulator devices, your app configuration should look like this:
IApp app = ConfigureApp
.iOS
.AppBundle("your.app.bundle")
.StartApp();
As of the time I'm writing this, there's also the instructions that InstalledApp "configures the installed app to use. Will force a run on physical device.", while AppBundle "Configures the app bundle to use. Will force a run on a simulator." These distinctions appear to be unique to iOS; the behavior is different on Android.
There's two other app configuration settings that may be applicable here: DeviceIdentifier and PreferIdeSettings. You can specify which device to run on with the Device Identifier, but the catch is that the simulators and devices will all have different ids on different machines, so be careful about checking that config in. PreferIdeSettings should allow you to use the Visual Studio for Mac device targeting -- see the test layout, unit test pad, and the test apps. Configured properly, you should see both an ios and android project, with the target showing something like Virtual Device / my_android_emulator (API 28) or Device / Your iPhone.

How to fix missing method exception in Xamarin.Forms PCL Android mobile app

I'm getting a System.MissingMethodException error after updating Xamarin.Forms package for Android Mobile App.
In MainActivity.cs line #22:
LoadApplication (new App ());
Application Output:
[] Missing method Android.Runtime.JNIEnv::StartCreateInstance(Type,string,JValue*) in assembly Mono.Android.dll, referenced in assembly /storage/emulated/0/Android/data/XAMLDataBindings_PCL.Droid/files/.__override__/Xamarin.Android.Support.v4.dll
I have tried Clean & Rebuild All as mentioned on the Xamarin forum but still not working. The project works for iOS so not sure why Android project won't run now?
I also had the same problem today. I removed all Xamarin.* NuGets from the Android project, re-installed Xamarin.Forms and it fetched the previous versions of Xamarin.Android.* NuGets, which is 21.0.3.0. All is working fine now. I am waiting for a fix.
I had the exact same error. Solved it by Upgrading instead of Downgrading which is a bit nicer.
'Xamarin Studio' -> 'Check for Updates'
Answered: "Up to date"
But when looking at the Solution tree at the left of the screen under your xxx.Droid project it wrote that the 'Packages' had some updates.
After opening the 'Packages' folder it tells you exactly which package can be updated.
Right click -> Update.
I updated the Xamarin.Android.Support.v4
It worked.
Enjoy.
I got this exception just for iOS simulator, cause I use tablet device for Android debugging. Eventually I found it just happened when computer had no Internet access.
So I think the real reason is: there is an exception caused by network, but Xamarin Studio can't give the real detail, and just can give a stupid fake exception like "System.MissingMethodException: Attempted to access a missing method."
In my case was the FloatingActionButton cause the problems!
FAB.Droid.FloatingActionButtonRenderer.InitControl();

Resources