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

[Bug] System.NotSupportedException: Unable to activate instance of type Project.Mobile.Droid.SplashScreenActivity from native handle 0xff957d6c (key_handle 0xefbe5c6). ---> System.MissingMethodException: No constructor found #11098

Closed
EDMIStephen opened this issue Jun 18, 2020 · 3 comments
Labels
has-stacktrace Bugs without reproductions but that contain a stack trace. i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often p/Android s/unverified New report that has yet to be verified t/bug 🐛

Comments

@EDMIStephen
Copy link

EDMIStephen commented Jun 18, 2020

Description

System.NotSupportedException. Seems similar to #6550 (comment)

Steps to Reproduce

  1. Build release build
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'InternalRelease|AnyCPU'">
    <DebugSymbols>True</DebugSymbols>    <!-- true Enable debugger -->
    <DebugType>full</DebugType>    <!-- full enables debugger -->
    <Optimize>false</Optimize>    <!-- false enables the debugger -->
    <AssemblyName>AppName.Mobile.Droid.Internal</AssemblyName>
    <OutputPath>bin\InternalRelease\</OutputPath>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
    <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
    <Debugger>Xamarin</Debugger>
    <RunCodeAnalysis>false</RunCodeAnalysis>
    <AndroidSupportedAbis>armeabi-v7a</AndroidSupportedAbis>
    <AndroidEnableMultiDex>true</AndroidEnableMultiDex>
    <AotAssemblies>true</AotAssemblies>
    <EnableLLVM>true</EnableLLVM>
    <AndroidAotMode>Hybrid</AndroidAotMode>
    <AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
    <AndroidDexTool>d8</AndroidDexTool>
    <AndroidLinkTool>r8</AndroidLinkTool>
    <AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
    <AndroidLinkMode>SdkOnly</AndroidLinkMode>
  </PropertyGroup>
  1. App crashes on startup

Expected Behavior

App doesn't crash

Actual Behavior

App crashes on Startup

06-18 16:29:46.604 I/MonoDroid(31387): UNHANDLED EXCEPTION:
06-18 16:29:46.608 I/MonoDroid(31387): System.NotSupportedException: Unable to activate instance of type appName.Mobile.Droid.SplashScreenActivity from native handle 0xff957d6c (key_handle 0xefbe5c6). ---> System.MissingMethodException: No constructor found for appName.Mobile.Droid.SplashScreenActivity::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
06-18 16:29:46.608 I/MonoDroid(31387):    --- End of inner exception stack trace ---
06-18 16:29:46.608 I/MonoDroid(31387):   at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00055] in <e614fdc5579e440e9326c8e09ff62c60>:0 
06-18 16:29:46.608 I/MonoDroid(31387):   at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00116] in <e614fdc5579e440e9326c8e09ff62c60>:0 
06-18 16:29:46.608 I/MonoDroid(31387):    --- End of inner exception stack trace ---
06-18 16:29:46.609 I/MonoDroid(31387):   at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00182] in <e614fdc5579e440e9326c8e09ff62c60>:0 
06-18 16:29:46.609 I/MonoDroid(31387):   at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000c1] in <e614fdc5579e440e9326c8e09ff62c60>:0 
06-18 16:29:46.609 I/MonoDroid(31387):   at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in <e614fdc5579e440e9326c8e09ff62c60>:0 
06-18 16:29:46.609 I/MonoDroid(31387):   at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <e614fdc5579e440e9326c8e09ff62c60>:0 
06-18 16:29:46.609 I/MonoDroid(31387):   at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in <e614fdc5579e440e9326c8e09ff62c60>:0 
06-18 16:29:46.609 I/MonoDroid(31387):   at Android.Content.ContextWrapper.n_AttachBaseContext_Landroid_content_Context_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native__base) [0x00000] in <e614fdc5579e440e9326c8e09ff62c60>:0 
06-18 16:29:46.609 I/MonoDroid(31387):   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.23(intptr,intptr,intptr)
06-18 16:29:46.621 W/rm.Mobile.Droi(31387): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
06-18 16:29:46.625 D/Mono    (31387): DllImport searching in: '__Internal' ('(null)').
06-18 16:29:46.625 D/Mono    (31387): Searching for 'java_interop_jnienv_throw'.
06-18 16:29:46.625 D/Mono    (31387): Probing 'java_interop_jnienv_throw'.
06-18 16:29:46.625 D/Mono    (31387): Found as 'java_interop_jnienv_throw'.
**System.NotSupportedException:** 'Unable to activate instance of type appName.Mobile.Droid.SplashScreenActivity from native handle 0xff957d6c (key_handle 0xefbe5c6).'

06-18 16:29:48.273 E/mono    (31387): 
06-18 16:29:48.273 E/mono    (31387): Unhandled Exception:
06-18 16:29:48.273 E/mono    (31387): System.NotSupportedException: Unable to activate instance of type appName.Mobile.Droid.SplashScreenActivity from native handle 0xff957d6c (key_handle 0xefbe5c6). ---> System.MissingMethodException: No constructor found for appName.Mobile.Droid.SplashScreenActivity::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
06-18 16:29:48.273 E/mono    (31387):    --- End of inner exception stack trace ---

Basic Information

  • Version with issue: 4.6.0.967, 4.7.0.937-Pre 4, 4.7.0.968. Havent tried any others
  • Last known good version: None found. Cannot roll back as far as 4.5.x.x.
  • IDE: VS Enterprise 16.3.10 (Newer versions have a Xamarin.Android bug for AOT compilation and CIL strip)
  • Platform Target Frameworks:
    • Android: 10.0
  • Android Support Library Version: 28.0.0.3
  • Nuget Packages:
    Core
<PackageReference Include="Acr.UserDialogs" Version="7.1.0.442" />
        <PackageReference Include="Autofac" Version="4.9.4" />
        <PackageReference Include="Autofac.Extras.MvvmCross" Version="5.1.0" />
        <PackageReference Include="AutoMapper" Version="9.0.0" />
        <PackageReference Include="Castle.Core" Version="4.4.0" />
        <PackageReference Include="Fody" Version="6.1.1" developmentDependency="true">
          <PrivateAssets>all</PrivateAssets>
          <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
        </PackageReference>
        <PackageReference Include="Microsoft.AppCenter" Version="3.2.1" />
        <PackageReference Include="Microsoft.AppCenter.Analytics" Version="3.2.1" />
        <PackageReference Include="Microsoft.AppCenter.Crashes" Version="3.2.1" />
        <PackageReference Include="Microsoft.AppCenter.Distribute" Version="3.2.1" />
        <PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
        <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.5" />
        <PackageReference Include="Microsoft.NETCore.Platforms" Version="3.1.1" />
        <PackageReference Include="Microsoft.NETCore.Targets" Version="3.1.0" />
        <PackageReference Include="MvvmCross" Version="6.4.2" />
        <PackageReference Include="MvvmCross.Forms" Version="6.4.2" />
        <PackageReference Include="MvvmCross.Plugin.Json" Version="6.4.2" />
        <PackageReference Include="NETStandard.Library" Version="2.0.3" />
        <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
        <PackageReference Include="NodaTime" Version="2.4.8" />
        <PackageReference Include="NodaTime.Serialization.JsonNet" Version="2.3.0" />
        <PackageReference Include="Plugin.BluetoothLE" Version="6.3.0.19" />
        <PackageReference Include="Plugin.LocalNotification" Version="5.0.4" />
        <PackageReference Include="PropertyChanged.Fody" Version="3.2.8" developmentDependency="true" />
        <PackageReference Include="Realm.Fody" Version="4.3.0">
          <PrivateAssets>all</PrivateAssets>
          <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
        </PackageReference>
        <PackageReference Include="runtime.native.System" Version="4.3.1" />
        <PackageReference Include="SkorXam.Pin" Version="1.0.1" />
        <PackageReference Include="System.Collections" Version="4.3.0" />
        <PackageReference Include="System.Collections.Concurrent" Version="4.3.0" />
        <PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
        <PackageReference Include="System.Diagnostics.Tools" Version="4.3.0" />
        <PackageReference Include="System.Diagnostics.Tracing" Version="4.3.0" />
        <PackageReference Include="System.Globalization" Version="4.3.0" />
        <PackageReference Include="System.IO" Version="4.3.0" />
        <PackageReference Include="System.IO.Compression" Version="4.3.0" />
        <PackageReference Include="System.Linq" Version="4.3.0" />
        <PackageReference Include="System.Linq.Expressions" Version="4.3.0" />
        <PackageReference Include="System.Net.Http" Version="4.3.4" />
        <PackageReference Include="System.Net.Primitives" Version="4.3.1" />
        <PackageReference Include="System.ObjectModel" Version="4.3.0" />
        <PackageReference Include="System.Reflection" Version="4.3.0" />
        <PackageReference Include="System.Reflection.Extensions" Version="4.3.0" />
        <PackageReference Include="System.Reflection.Primitives" Version="4.3.0" />
        <PackageReference Include="System.Resources.ResourceManager" Version="4.3.0" />
        <PackageReference Include="System.Runtime" Version="4.3.1" />
        <PackageReference Include="System.Runtime.Extensions" Version="4.3.1" />
        <PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
        <PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
        <PackageReference Include="System.Runtime.Numerics" Version="4.3.0" />
        <PackageReference Include="System.Text.Encoding" Version="4.3.0" />
        <PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
        <PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
        <PackageReference Include="System.Threading" Version="4.3.0" />
        <PackageReference Include="System.Threading.Tasks" Version="4.3.0" />
        <PackageReference Include="System.Threading.Timer" Version="4.3.0" />
        <PackageReference Include="System.Xml.ReaderWriter" Version="4.3.1" />
        <PackageReference Include="System.Xml.XDocument" Version="4.3.0" />
        <PackageReference Include="TimeZoneConverter" Version="3.2.0" />
        <PackageReference Include="Xamanimation" Version="1.3.0" />
        <PackageReference Include="Xamarin.Forms" Version="4.6.0.967" />
        <PackageReference Include="Xamarin.Essentials" Version="1.5.3.2" />
        <PackageReference Include="ZXing.Net.Mobile" Version="2.4.1" />
        <PackageReference Include="ZXing.Net.Mobile.Forms" Version="2.4.1" />

Droid

    <PackageReference Include="Autofac.Extras.MvvmCross" Version="5.1.0" />
    <PackageReference Include="Fody"" Version="6.1.1" />
    <PackageReference Include="Nito.Collections.Deque" Version="1.0.4" />
    <PackageReference Include="Microsoft.Win32.Primitives" Version="4.3.0" />
    <PackageReference Include="FodyHelpers" Version="6.1.1" />
    <PackageReference Include="Microsoft.AppCenter.Analytics" Version="3.2.1" />
    <PackageReference Include="Microsoft.AppCenter.Crashes" Version="3.2.1" />
    <PackageReference Include="MvvmCross.Forms" Version="6.4.2" />
    <PackageReference Include="MvvmCross.Plugin.Json" Version="6.4.2" />
    <PackageReference Include="Realm" Version="4.3.0" />
    <PackageReference Include="Realm.Fody"" Version="4.3.0" />
    <PackageReference Include="Serilog.Sinks.Xamarin" Version="0.2.0.64" />
    <!-- https://github.com/xamarin/xamarin-android/issues/4731 for System.Runtime.Loader fix with AOT compilation -->
    <PackageReference Include="System.Runtime.Loader" Version="4.3.0">
      <ExcludeAssets>all</ExcludeAssets>
    </PackageReference>
    <PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
    <PackageReference Include="System.ValueTuple" Version="4.5.0" />
    <PackageReference Include="Xamarin.Android.Support.Compat" Version="28.0.0.3" />
    <PackageReference Include="Xamarin.AndroidX.AppCompat.Resources" Version="1.1.0.1" />
    <PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.2.0.1" />
    <PackageReference Include="Xamarin.AndroidX.Browser" Version="1.2.0.1" />
    <PackageReference Include="Xamarin.AndroidX.Work.Runtime" Version="2.3.4.3" />
    <PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.1.0.1" />
    <PackageReference Include="Xamarin.Google.Android.Material" Version="1.0.0.1" />
    <PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.1" />
    <PackageReference Include="Xamarin.Android.Arch.Core.Common" Version="1.1.1.3" />
    <PackageReference Include="Xamarin.Android.Arch.Lifecycle.Common" Version="1.1.1.3" />
    <PackageReference Include="Xamarin.Android.Arch.Lifecycle.Runtime" Version="1.1.1.3" />
    <PackageReference Include="Xamarin.Build.Download" Version="0.10.0" />
    <PackageReference Include="Xamarin.Firebase.Common" Version="71.1610.1" />
    <PackageReference Include="Xamarin.Firebase.Iid" Version="71.1710.1" />
    <PackageReference Include="Xamarin.Firebase.Messaging" Version="71.1740.1" />
    <PackageReference Include="Xamarin.GooglePlayServices.Basement" Version="71.1620.2" />
    <PackageReference Include="Xamarin.GooglePlayServices.Tasks" Version="71.1601.1" />
    <PackageReference Include="Xamarin.Essentials" Version="1.5.3.2" />
    <PackageReference Include="Xamarin.Forms" Version="4.6.0.967" />
    <PackageReference Include="ZXing.Net.Mobile" Version="2.4.1" />
    <PackageReference Include="ZXing.Net.Mobile.Forms" Version="2.4.1" />
  • Affected Devices: All

Reproduction Link

Will try get one going but can you please start investigating on stack trace.

Workaround

None as of yet

@EDMIStephen EDMIStephen added s/unverified New report that has yet to be verified t/bug 🐛 labels Jun 18, 2020
@samhouts samhouts added has-stacktrace Bugs without reproductions but that contain a stack trace. i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often p/Android labels Jun 18, 2020
@samhouts
Copy link
Member

This is probably due to the linker removing your splash page. Please review this documentation: https://docs.microsoft.com/en-us/xamarin/android/deploy-test/linker Thanks!

@acuntex
Copy link
Contributor

acuntex commented Jul 20, 2020

@samhouts It could be a general problem that Xamarin.Forms somehow asks for this specific constructor.

I created a Repro here: https://github.com/acuntex/PancakeViewBug_TitleView

Workaround is documented here: sthewissen/Xamarin.Forms.PancakeView#113

And the workaround is also dangerous because the DependencyResolver of Xamarin.Forms (https://github.com/xamarin/Xamarin.Forms/blob/719fc7a604ff0cce8922d717c99bfb0fa17e35e0/Xamarin.Forms.Core/DependencyResolver.cs) has a pretty dirty workaround in line 50, which checks if the constructor has two parameters (without any type checking) and then fails because it does not match. (Just a little appeal to stop fixing bugs with workarounds that require further workarounds that require further workarounds that..)

I urge you to not dismiss this problem as some "linker issue" because it is not.

@EDMIStephen
Copy link
Author

@samhouts It could be a general problem that Xamarin.Forms somehow asks for this specific constructor.

I created a Repro here: https://github.com/acuntex/PancakeViewBug_TitleView

Workaround is documented here: sthewissen/Xamarin.Forms.PancakeView#113

And the workaround is also dangerous because the DependencyResolver of Xamarin.Forms (https://github.com/xamarin/Xamarin.Forms/blob/719fc7a604ff0cce8922d717c99bfb0fa17e35e0/Xamarin.Forms.Core/DependencyResolver.cs) has a pretty dirty workaround in line 50, which checks if the constructor has two parameters (without any type checking) and then fails because it does not match. (Just a little appeal to stop fixing bugs with workarounds that require further workarounds that require further workarounds that..)

I urge you to not dismiss this problem as some "linker issue" because it is not.

For us I think in the end it was a Xamarin Android bug related to hybrid AOT.
dotnet/android#4850

We manually made the change to src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets from that PR and it seemed to resolve the issue. We also needed to support armv7a & arm64-v8a due to this bug:
dotnet/android#1218

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
has-stacktrace Bugs without reproductions but that contain a stack trace. i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often p/Android s/unverified New report that has yet to be verified t/bug 🐛
Projects
None yet
Development

No branches or pull requests

3 participants