Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Android app crashes since updating to Xamarin Forms v4 #7602

Closed
dannythomas13 opened this issue Sep 20, 2019 · 56 comments
Closed

[Bug] Android app crashes since updating to Xamarin Forms v4 #7602

dannythomas13 opened this issue Sep 20, 2019 · 56 comments
Labels
i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often i/regression p/Android t/bug 🐛

Comments

@dannythomas13
Copy link

dannythomas13 commented Sep 20, 2019

Since updating to 4.2.0.815419 I now get the following exception thrown at LoadApplication(new App(dbPath, builder)); within MainActivity.cs

I did also try v4.3.0.819712-pre2 in case there was a fix contained.

I will have to rollback to 3.5.0.129452 but I thought it would be useful to log the issue.

Linking is set to None. UWP app does work.

09-25 13:17:14.076 E/mono    ( 5126): 
09-25 13:17:14.076 E/mono    ( 5126): Unhandled Exception:
09-25 13:17:14.076 E/mono    ( 5126): System.TypeLoadException: Could not load type of field 'Xamarin.Forms.Platform.Android.RendererPool:_freeRenderers' (0) due to: Could not resolve type with token 01000275 from typeref (expected class 'System.Collections.Generic.Stack`1' in assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e') assembly:mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e type:System.Collections.Generic.Stack`1 member:(null)
09-25 13:17:14.076 E/mono    ( 5126):   at (wrapper dynamic-method) System.Object.7(intptr,intptr,intptr)
09-25 13:17:14.076 E/mono    ( 5126):   at (wrapper native-to-managed) System.Object.7(intptr,intptr,intptr)
09-25 13:17:14.076 E/mono-rt ( 5126): [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type of field 'Xamarin.Forms.Platform.Android.RendererPool:_freeRenderers' (0) due to: Could not resolve type with token 01000275 from typeref (expected class 'System.Collections.Generic.Stack`1' in assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e') assembly:mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e type:System.Collections.Generic.Stack`1 member:(null)
09-25 13:17:14.076 E/mono-rt ( 5126):   at (wrapper dynamic-method) System.Object.7(intptr,intptr,intptr)
09-25 13:17:14.076 E/mono-rt ( 5126):   at (wrapper native-to-managed) System.Object.7(intptr,intptr,intptr)
@dannythomas13 dannythomas13 added s/unverified New report that has yet to be verified t/bug 🐛 labels Sep 20, 2019
@pauldipietro pauldipietro added this to New in Triage Sep 20, 2019
@jfversluis
Copy link
Member

From a first glance this does seem like some kind of caching issue. Make sure you updated all the projects to the same version of Xamarin.Forms, then clean the solution. To be sure delete the bin and obj folders from each of the projects as well on the filesystem. Also remove the app from the emulator or device.

Do a rebuild, run and hopefully all should be resolved. Did you try any of these things already?

@davidbuckleyni
Copy link

I found that I had to uninstall any existing 3.0 apps on the phone and re deploy clean and build your solution then should be ok. Could well be hot reload has happened a few times for me so make sure that this is disabled.

@dannythomas13
Copy link
Author

Hi @jfversluis these issues actually also occur on devops and appcenter, both areas clean the working area before any build I believe

@jfversluis
Copy link
Member

jfversluis commented Sep 20, 2019

Searching for this error message it seems to have to do with the Android targeting and support packages. Did you update those as well? Could you provide some more info on what packages are installed exactly with which version and what Android version you are trying to target?

@davidbuckleyni
Copy link

davidbuckleyni commented Sep 20, 2019 via email

@KennyMack
Copy link

i having the same issue after update to latest version, in the previous version everything works fine, but when i update the xamarin the error occurs.

@samhouts samhouts added i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often i/regression p/Android labels Sep 20, 2019
@samhouts
Copy link
Member

Can anyone experiencing this issue please attach a small project that demonstrates this issue? Thanks!

@samhouts samhouts added s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Sep 20, 2019
@samhouts samhouts moved this from New to Needs Info in Triage Sep 20, 2019
@jfversluis
Copy link
Member

I see someone with the same issue here on SO: https://stackoverflow.com/questions/58032635/updating-nuget-caused-exception-unhandled-system-typeloadexception

It seems to have to do with Maps? Can someone verify this? And what Samantha said, a reproduction would be super awesome!

@GZidar
Copy link

GZidar commented Sep 21, 2019

I have the exact same issue, in both Android and iOS. On Android the app builds and crashes upon start up on iOS the app does not build (when targeting a real device simulator build works fine). I get the error referenced in the Stack overflow link above relating to System.Collections.Generic.Stack`1

The problem does not exist if I revert back to 4.2.0.778463

I am not sure if it is related to maps, but my app does include the Maps nuget package.

@KennyMack
Copy link

I don't use maps, that's occur even in a fresh project

@jfversluis
Copy link
Member

@KennyMack would you be able to put that in a reproduction project and add that here?

@KoenMat
Copy link

KoenMat commented Sep 23, 2019

I got the same error upgrading to 4.2 SR2.
I tried several suggestions, updated all nuget-packages, but app still crashed.
I started a new blank app (in 4.0), works fine!
Upgraded tot 4.2 SR2, crashed!
Then I updated Visual Studio (16.2.5), and the problem was gone!!

@MagicAndre1981
Copy link
Contributor

@KennyMack would you be able to put that in a reproduction project and add that here?

I simply created a new empty app and also get a TypeLoadException (but without any details) in VS2017 15.9

image

@MagicAndre1981
Copy link
Contributor

Then I updated Visual Studio (16.2.5), and the problem was gone!!

with VS2019 I'm also able to compile and run the app without any issue.

@jfversluis Any ideas why it fails for VS2017? Is this a Mono issue with VS2017 15.9?

@KennyMack
Copy link

@jfversluis Here the project, i just create and update the xamarin to version 4.2.0.815419 and app crash when start
https://github.com/KennyMack/ExampleFail

@hartez hartez removed s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Sep 24, 2019
@hartez hartez moved this from Needs Info to New in Triage Sep 24, 2019
@cyberaxcess
Copy link

I had the same issue using AppCenter, also using 4.2.0.815419 both iOS and Android builds failed with the same "expected class 'System.Collections.Generic.Stack" message.

I changed the build configuration in AppCenter to use: SDK Version: Xamarin.iOS 12.14 and Xcode version: 10.3.
The problem seems to have gone away now since changing to these settings, on the iOS builds (haven't tried the Android yet).

@PureWeen
Copy link
Contributor

@KennyMack I pulled down your repro and it all works fine for me

image

@MaartenBrandemann
Copy link

@ryanmendoza To fix the iOS devops build, you need to use xCode 11 and Xamarin sdk 6_4_0. Add build task "Use .NET Core" to the pipeline using version 3.0.100.

@jfversluis
Copy link
Member

@ryanmendoza

Seconding that this issue is affecting build pipelines on DevOps using macOS 10.14. Is there any short term fix or are we stuck waiting for a new 4.2.X version?

There is actually a new version now, does that fix things for you?

@samhouts
Copy link
Member

This should be resolved in the latest versions of Xamarin.Forms published on NuGet. Thank you!

Triage automation moved this from Needs Estimate to Closed Oct 17, 2019
@MagicAndre1981
Copy link
Contributor

This should be resolved in the latest versions of Xamarin.Forms published on NuGet.

which version/build number? How long will XF work for VS2017 users?

@samhouts
Copy link
Member

4.2.0.848062 and 4.3.0.851321-pre3 are both compatible with VS2017.

@GZidar
Copy link

GZidar commented Oct 19, 2019

I can confirm that using the latest builds (mentioned above) has resolved the reported issue without the need to upgrade / change your existing tooling.

@MagicAndre1981
Copy link
Contributor

4.2.0.848062 ... compatible with VS2017.

thanks, I can confirm this.

@charlesroddie
Copy link

There is no point in getting new versions of Xamarin.Forms to work with old tooling. People who want to use old tooling can still use old versions of Xamarin.Forms. Needing to support old tooling would be a drag on development in a repo that already has too many drags on development.

@Sonic3R
Copy link

Sonic3R commented Nov 22, 2019

I got same issue on Xamarin.Forms.iOS version 4.3.0.991211 on MacOS Mojave

@dbeylkhanov
Copy link

dbeylkhanov commented Dec 3, 2019

@samhouts this issue is closed, but the problem still exists...Where is the official solution, or give to us at least the working workaround to fix this issue, please?

Look at build log in Azure DevOps:
image

Project type - Xamarin.iOS
Mono - 5.12.0
XCode - 10.2.1

my .yaml configuration in Azure DevOps

@jfversluis
Copy link
Member

@beylkhanovdamir what version of Xamarin.Forms are you using? This should not happen anymore after the earlier mentioned versions

@Sonic3R
Copy link

Sonic3R commented Dec 3, 2019

@jfversluis It still happens to me too (Xamarin.Forms.iOS version 4.3.0.991211)

@jfversluis
Copy link
Member

@Sonic3R you are using VS2017 on Windows? VSMac? Can you give some more details?

@Sonic3R
Copy link

Sonic3R commented Dec 3, 2019

Visual Studio for Mac, version 8.3

@dbeylkhanov
Copy link

dbeylkhanov commented Dec 3, 2019

@jfversluis you can look at my .yaml configuration in DevOps

p.s. I'm using 'macOS-latest' vmImage and XF version below
image

@jfversluis
Copy link
Member

jfversluis commented Dec 3, 2019

@beylkhanovdamir did you see this comment: #7602 (comment)

I see you're setting the SDK version manually and you're using Xcode 10, you might want to look into using current versions together with the newest Forms version.

@Sonic3R could you share a little bit more about what errors you are seeing in VSMac when building? What version of Xcode are you using?

@davidbuckleyni
Copy link

davidbuckleyni commented Dec 3, 2019 via email

@dbeylkhanov
Copy link

dbeylkhanov commented Dec 3, 2019

@jfversluis

did you see this comment: #7602 (comment)

yes, I saw, but I can't, because we have a project where target FW is .netstandard 2.0 (i.e. not 2.1 which is compatible with .net core 3.0), and in this case, I will get a lot of compilation errors.
But perhaps, for now, it's really the last way to fix this issue

@Siva-netdev
Copy link

Hi - Getting the below error message on Visual studio 2017 supports Xamarin.iOS 12.4.0.64. Someone please assist us on this as it blocked our complete deployment process now.

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(795,3): error MT2002: Failed to resolve "System.Collections.Generic.Stack`1" reference from "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"

This error message comes ONLY after paring with mac which has same Xamarin.iOS, latest xCode and mono 5.18.

Thanks in advance

@RuddyOne
Copy link

RuddyOne commented Mar 9, 2020

@ryanmendoza To fix the iOS devops build, you need to use xCode 11 and Xamarin sdk 6_4_0. Add build task "Use .NET Core" to the pipeline using version 3.0.100.

What does this even mean? I'm pretty confused by this, do you have example YAML you could share?

What am I building with .netcore task? The iOS project.. how? I clearly am missing something.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often i/regression p/Android t/bug 🐛
Projects
None yet
Development

No branches or pull requests