xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Bug] Android App Crashes (Only in Android 12 - SDK 31) when trying to inflate a Tabbed Page after a WebView #15027

Open deepak-surya opened 2 years ago

deepak-surya commented 2 years ago

Description

Steps to Reproduce

  1. Set any Page as the Main Page.
  2. Have a Xamarin WebView Render in this Page.
  3. On the WebView Navigated Event, Set the Main Page of the App to be a Tabbed Page / AppShell
  4. Crash Happens when trying to inflate the Tabbed Page

Expected Behavior

The application shouldn't be crashed

Actual Behavior

The Application is getting Crashed (This happens only on Android 12, Android 11 & Below Devices & iOS Devices works fine with the same code logics)

Basic Information

Environment

Show/Hide Visual Studio info ``` === Visual Studio Community 2019 for Mac === Version 8.10.14 (build 17) Installation UUID: e942bb7a-805b-4670-8f3c-3e66c43dafe6 GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638) Package version: 612000140 === Mono Framework MDK === Runtime: Mono 6.12.0.140 (2020-02/51d876a041e) (64-bit) Package version: 612000140 === Roslyn (Language Service) === 3.10.0-4.21269.26+029847714208ebe49668667c60ea5b0a294e0fcb === NuGet === Version: 5.9.0.7134 === .NET Core SDK === SDK: /usr/local/share/dotnet/sdk/6.0.100-rc.1.21463.6/Sdks SDK Versions: 6.0.100-rc.1.21463.6 5.0.403 5.0.402 5.0.401 5.0.302 3.1.415 3.1.414 3.1.413 3.1.411 MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks === .NET Core Runtime === Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 6.0.0-rc.1.21451.13 5.0.12 5.0.11 5.0.10 5.0.8 3.1.21 3.1.20 3.1.19 3.1.17 === .NET Core 3.1 SDK === SDK: 3.1.415 === Xamarin.Profiler === Version: 1.7.0.0 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler === Updater === Version: 11 === Xamarin Designer === Version: 16.11.0.39 Hash: cd672761d Branch: remotes/origin/d16-11 Build date: 2021-10-06 21:09:18 UTC === Apple Developer Tools === Xcode 13.2.1 (19586) Build 13C100 === Xamarin.Mac === Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version. === Xamarin.iOS === Version: 15.2.0.17 (Visual Studio Community) Hash: 738fde344 Branch: xcode13.1 Build date: 2021-11-09 02:45:16-0500 === Xamarin.Android === Version: 12.0.0.3 (Visual Studio Community) Commit: xamarin-android/d16-11/f0e3c2d Android SDK: /Users/itsupportavasoft/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: 7.1 (API level 25) SDK Tools Version: 26.1.1 SDK Platform Tools Version: 31.0.3 SDK Build Tools Version: 30.0.2 Build Information: Mono: c633fe9 Java.Interop: xamarin/java.interop/d16-11@476bb5b ProGuard: Guardsquare/proguard/v7.0.1@912d149 SQLite: xamarin/sqlite/3.35.4@85460d3 Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-11@87af37b === Eclipse Temurin JDK === Java SDK: Not Found === Android SDK Manager === Version: 16.10.0.13 Hash: 1b81df5 Branch: remotes/origin/d16-10 Build date: 2021-11-12 01:17:32 UTC === Android Device Manager === Version: 16.10.0.15 Hash: 89dcc0b Branch: remotes/origin/d16-10 Build date: 2021-11-12 01:17:52 UTC === Build Information === Release ID: 810140017 Git revision: 6f93cf55df3b7747288286e2006057c7f088b838 Build date: 2021-11-12 09:50:18-05 Build branch: release-8.10 === Operating System === Mac OS X 12.0.1 Darwin 21.1.0 Darwin Kernel Version 21.1.0 Wed Oct 13 17:33:23 PDT 2021 root:xnu-8019.41.5~1/RELEASE_X86_64 x86_64 ```

Build Logs

Screenshots

image

Screenshot 2022-01-05 at 8 00 54 PM

image

Reproduction Link

Workaround

jfversluis commented 2 years ago

It would be very helpful if you could get the relevant pieces into a new Xamarin.Forms project and create a reproduction for us to look at. Would you be able to do that?

At the very least I would love to get the stacktrace as text instead of images.

dimonovdd commented 2 years ago

At the very least I would love to get the stacktrace as text instead of images.

Hi. I have the same behavior with FlyoutPage. But I can't even catch any logs or stack trace

themronion commented 2 years ago

if it helps, this code also causes this issue: in MainActivity ->

       public override Resources Resources
        {
            get
            {
                var config = base.Resources.Configuration;
                if (config == null)
                    config = new Configuration();
                config.FontScale = 1f;
                return CreateConfigurationContext(config).Resources;
            }
        }
kamilol commented 2 years ago

@themronion you can use ApplicationContext.CreateConfigurationContext(configuration).Resources, CreateConfigurationContext(configuration).Resources (from base MainActivity throws error)

themronion commented 2 years ago

@themronion you can use ApplicationContext.CreateConfigurationContext(configuration).Resources, CreateConfigurationContext(configuration).Resources (from base MainActivity throws error)

Thanks! 🙏 That fixes it

philtomblin commented 2 years ago

I'm seeing the same issue. I have an app that works perfectly for Android v11 (and earlier), but that crashes immediately on launching Shell following a web view. The web view happens to be doing an Azure B2C login using MSAL so I have no workaround. Also, for reasons unknown, the debugger refuses to connect (again, only for the v12 emulator) so I have no stack trace. I'm using VS for Mac.