I'm facing a strange issue which I couldn't reproduce on my end. However some users are reporting that the App stucks on the Splashscreen.
It seems to be all Android 10 devices, however my Emulators running Android 10 are working fine.
First I thought that my release build settings where the problems, however I tried all combinations.
None is working on the users side.
This is what I got now for my release build settings.
Target: Android 10
Linking: SDK Only
AOT with startup tracing enabled
Multidex: Disabled
Codeshrinker: None
Dex compiler: D8
It seems to came up with XF5, before that, no body has reported such an issue.
This is my splash:
using Android.App;
using Android.Content.PM;
using Android.Content.Res;
using Android.OS;
namespace RemoteControlRepetierServer.Droid
{
[Activity(Theme = "@style/Splash", MainLauncher = true, NoHistory = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode)]
public class SplashActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
StartActivity(typeof(MainActivity));
Finish();
}
public override void OnConfigurationChanged(Configuration newConfig) { base.OnConfigurationChanged(newConfig); } }
}
An this my main activity.
[Activity(Label = "RemoteControlRepetierServer", Icon = "@mipmap/ic_launcher", Theme = "@style/MainTheme",
MainLauncher = false, ConfigurationChanges = ConfigChanges.UiMode | ConfigChanges.ScreenSize | ConfigChanges.Orientation,
LaunchMode = LaunchMode.SingleTop
)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
internal static MainActivity Instance { get; private set; }
internal static App SingleInstance { get; private set; }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); // Needed for LibVlc Platform.Init(this); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); // Barcode scanning //ZXing.Net.Mobile.Forms.Android.Platform.Init(); // Plugin.LocalNotification NotificationCenter.CreateNotificationChannel(); LoadApplication(new App()); NotificationCenter.NotifyNotificationTapped(Intent); //CreateNotificationFromIntent(Intent); } public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults) { Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults); // Barcode scanning //global::ZXing.Net.Mobile.Android.PermissionsHandler.OnRequestPermissionsResult(requestCode, permissions, grantResults); base.OnRequestPermissionsResult(requestCode, permissions, grantResults); } #region Notifications protected override void OnNewIntent(Intent intent) { NotificationCenter.NotifyNotificationTapped(intent); base.OnNewIntent(intent); //CreateNotificationFromIntent(intent); } #endregion }
Has anybody the same issue? Or an idea how to solve or debug such an issue?
@Yelinzh said:
Waiting for your update.
So after 4 days of try and error, I finally figured it out.
So, I have a LoadingPage. This page is loaded as first ShellItem.
On this LoadingPage at OnAppearing() I check if the server is configured, and if it is, if it's reachable.
public async Task OnAppearing()
{
try
{
LoadSettings();
IsBusy = true;
if (IsStartUp) { // Avoids freezes on some devices if (Device.RuntimePlatform == "Android") { await Task.Delay(250); // <= Fixed it } await CheckConfigurationAction(); } else { await RecheckConfigurationAction(); } } catch (Exception exc) { // Log error EventManager.LogError(exc); } IsBusy = false; IsStartUp = false; }
So the problem was, that I directly navigated from the "OnAppearing()" event to a WelcomePage.xml if the server is not configured (first visit).
private async Task CheckConfigurationAction()
{
try
{
int delay = Device.RuntimePlatform == "Android" ? 150 : 50;
IsChecking = true;
if (!IsDemoModeOn)
{
if (LastServerId == Guid.Empty || Servers.Count == 0)
await ShellNavigationManager.GoToAsync(ShellRoute.PrintServerWelcomePage, false, delay);
else
{
await RecheckConfigurationAction();
}
}
else
{
IsReachable = true;
await ShellNavigationManager.GoToAsync("///Dashboard", false, delay);
}
}
catch (Exception exc)
{
// Log error
EventManager.LogError(exc);
}
IsChecking = false;
}
I fixed it by only adding a Delay of 250ms in the OnAppearing() before I call Shell.Current.GoToAsync()
I was doing this explicit on the MainThread without a catch block, so it crashed and stopped.
Thanks,
Andreas
Answers
Hi, AndreasR. I created a basic demo with Xamarin.Forms 5.0 to test the code, it works fine on Android 10. Does the problem occur on a specific device? Please check that.
You could try to downgrade the Xamarin.Forms package to 4.8 version to vertify it.
Xamarin forums are migrating to a new home on Microsoft Q&A!
We invite you to post new questions in the Xamarin forums’ new home on Microsoft Q&A!
For more information, please refer to this sticky post.
Hi @Yelinzh
Thank you for your reply.
One user who have reported this issue has a Huawei P30 Pro.
The other has a Honor 10i.
On my emulator running Android 10 it's also working. Using my Huawei Honor 9, using Android 9, it's also working.
I just can't reproduce this issue on my end.
The app it self is available for testing (free) here:
https://play.google.com/apps/testing/com.andreasreitberger.repservapp
If this helps.
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 0 >>> com.andreasreitberger.repservapppro <<<
backtrace:
#00 pc 000000000006f06c /apex/com.android.runtime/lib64/bionic/libc.so (abort+160)
#00 pc 000000000028a1b8 /data/app/com.andreasreitberger.repservapppro-OLHLSGOQe9Wz9x0jbyvJzg==/split_config.arm64_v8a.apk!lib/arm64-v8a/libmonosgen-2.0.so (offset 0xfff000) (monoeg_assert_abort+24)
Both are using the device with the same brand. Try testing the code on a Huawei device with Android 10 to check the issue.
Some users using Samsung devices also reporting this issue. Seems not to be related only with Huawei.
I tried the downgrade Xamarin.Forms to 4.8, and the issue is the same on the users Huawei Honor 10i.
So I went completely back to the last working version and the major change I did, was to set the NetStandard from 2.0 to 2.1.
I'll make some further investigation on this and report back once I found what's causing this issue.
Thanks,
Andreas
Waiting for your update.
So after 4 days of try and error, I finally figured it out.
So, I have a LoadingPage. This page is loaded as first ShellItem.
On this LoadingPage at OnAppearing() I check if the server is configured, and if it is, if it's reachable.
public async Task OnAppearing()
{
try
{
LoadSettings();
IsBusy = true;
So the problem was, that I directly navigated from the "OnAppearing()" event to a WelcomePage.xml if the server is not configured (first visit).
private async Task CheckConfigurationAction()
{
try
{
int delay = Device.RuntimePlatform == "Android" ? 150 : 50;
IsChecking = true;
if (!IsDemoModeOn)
{
if (LastServerId == Guid.Empty || Servers.Count == 0)
await ShellNavigationManager.GoToAsync(ShellRoute.PrintServerWelcomePage, false, delay);
else
{
await RecheckConfigurationAction();
}
}
else
{
IsReachable = true;
await ShellNavigationManager.GoToAsync("///Dashboard", false, delay);
}
}
catch (Exception exc)
{
// Log error
EventManager.LogError(exc);
}
IsChecking = false;
}
I fixed it by only adding a Delay of 250ms in the OnAppearing() before I call Shell.Current.GoToAsync()
I was doing this explicit on the MainThread without a catch block, so it crashed and stopped.
Thanks,
Andreas
Congrats! Please accept your solution as the answer. It will be beneficial for other community members who have similar questions.