Xamarin.forms: [Bug] App crashes after updating to v4.2.0.709249

Created on 28 Aug 2019  路  16Comments  路  Source: xamarin/Xamarin.Forms

Description

After updating to v4.2.0.709249 from v4.1.0.709244 the app is immediately crashing on startup with the following exception
`
0xFFFFFFFFFFFFFFFF in System.Diagnostics.Debugger.Mono_UnhandledException_internal C#
0x1 in System.Diagnostics.Debugger.Mono_UnhandledException C#
0x20 in Android.Runtime.DynamicMethodNameCounter.9 C#
0x1 in Xamarin.Forms.Platform.Android.AppCompat.Platform.op_Implicit at D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:491,4 C#
0x3B in Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnDestroy at D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:221,4 C#
0xA in Android.App.Activity.n_OnDestroy C#
0x11 in Android.Runtime.DynamicMethodNameCounter.9 C#

`

Steps to Reproduce

  1. Update Xamarin.Forms nuget package to v4.2.0.709249
  2. Start an app
  3. 3.

Expected Behavior

App starts

Actual Behavior

App crashes

Basic Information

  • Version with issue: v4.2.0.709249 f
  • Last known good version: v4.1.0.709244
  • IDE: Visual Studio 2019 16.2.3
  • Platform Target Frameworks:

    • Android: 28

  • Android Support Library Version: 28.0.0.1
1 high regression Android bug

Most helpful comment

To pinpoint the issue it seems that calling on destroy in a FormsAppCompatActivity gives us a crash in latest XF.

For all of you using splashacitivities use AppCompatActivity instead of the FormsAppCompatActivity.

@WilliamWatterson86 since youre probably not using anything Xamarin.Forms related in your splashactivity there will be no problem with this.

All 16 comments

someone here is having the same problem

@anpin Are you experiencing the same issue as https://github.com/xamarin/Xamarin.Forms/issues/7283? If not, can you please attach a small project that demonstrates this issue? Thanks!

Similar to this problem I am experiencing?

https://github.com/xamarin/Xamarin.Forms/issues/7286

Having to downgrade now. This version is unusable for me

I had the exact issue, fixed it by changing my splashactivity from FormsAppCompatActivity to AppCompatActivity

@bentmar - that seems to work for me too. Is there any side effect of doing this do you think?

@anpin @bentmar can you please provide a small repo so we can investigate further.

Thanks

My issue is similar (related?), but instead of crashing on startup, it crashes when going back to the launcher:
Visual Studio 2019 on Windows 10, Google Pixel 2

  1. In VS 2019, create new Mobile App (Xamarin.Forms) project
  2. Pick Shell template with all defaults (defaults to Xamarin.Forms 4.1)
  3. Run debug version on device (mine is a Pixel 2)
  4. Click system back button to return to system launcher
  5. App works fine and you can switch back to the app
  6. Upgrade Xamarin.Forms NuGet to latest 4.2
  7. Run again in debug
  8. Click back like before
  9. Now it gets null reference exception

App is not crashing with a new blank project with XF v4.2.0.709249, but if I'm adding a splash activity to the app it crashes with the same error right after MainActivity is shown
0xFFFFFFFFFFFFFFFF in System.Diagnostics.Debugger.Mono_UnhandledException_internal C# 0x1 in System.Diagnostics.Debugger.Mono_UnhandledException C# 0x20 in Android.Runtime.DynamicMethodNameCounter.9 C# 0x1 in Xamarin.Forms.Platform.Android.AppCompat.Platform.op_Implicit at D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:491,4 C# 0x3B in Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnDestroy at D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:221,4 C# 0xA in Android.App.Activity.n_OnDestroy C# 0x11 in Android.Runtime.DynamicMethodNameCounter.9 C#
Sample project with error is in attach
App1.zip

To pinpoint the issue it seems that calling on destroy in a FormsAppCompatActivity gives us a crash in latest XF.

For all of you using splashacitivities use AppCompatActivity instead of the FormsAppCompatActivity.

@WilliamWatterson86 since youre probably not using anything Xamarin.Forms related in your splashactivity there will be no problem with this.

Same here:

at Java.Interop.JniPeerMembers/JniInstanceMethods.InvokeVirtualVoidMethod (string,Java.Interop.IJavaPeerable,Java.Interop.JniArgumentValue) [0x0005f] in :0
at Android.App.Activity.OnDestroy () [0x00012] in :0
at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnDestroy () [0x00060] in D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat*
FormsAppCompatActivity.cs:228**
at Android.App.Activity.n_OnDestroy (intptr,intptr) [0x0000a] in :0
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.24 (intptr,intptr) [0x00011] in :0
at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.24 (intptr,intptr) [0x00033] in :0

Look at FormsAppCompatActivity.cs:228.

@rmarinho

App is not crashing with a new blank project with XF v4.2.0.709249, but if I'm adding a splash activity to the app it crashes with the same error right after MainActivity is shown
0xFFFFFFFFFFFFFFFF in System.Diagnostics.Debugger.Mono_UnhandledException_internal C# 0x1 in System.Diagnostics.Debugger.Mono_UnhandledException C# 0x20 in Android.Runtime.DynamicMethodNameCounter.9 C# 0x1 in Xamarin.Forms.Platform.Android.AppCompat.Platform.op_Implicit at D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:491,4 C# 0x3B in Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnDestroy at D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:221,4 C# 0xA in Android.App.Activity.n_OnDestroy C# 0x11 in Android.Runtime.DynamicMethodNameCounter.9 C#
Sample project with error is in attach
App1.zip

someone here is having the same problem

Yeah I got the same issue as @anpin during my SplashScreen OnDestroy() Activity

Same here

[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] System.NullReferenceException: Object reference not set to an instance of an object.
[MonoDroid]   at Xamarin.Forms.Platform.Android.AppCompat.Platform.op_Implicit (Xamarin.Forms.Platform.Android.AppCompat.Platform canvas) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:491 
[MonoDroid]   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnDestroy () [0x0002f] in D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:221 
[MonoDroid]   at Android.App.Activity.n_OnDestroy (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <14fc11fa46a741ab9dde75db7823aece>:0 
[MonoDroid]   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.17(intptr,intptr)

I had the exact issue, fixed it by changing my splashactivity from FormsAppCompatActivity to AppCompatActivity

I've also solved this way

7706 Should fix this. If not, please re-open.

Was this page helpful?
0 / 5 - 0 ratings