Xamarin caused by: android.runtime.JavaProxyThrowable: MvvmCross.Exceptions.MvxIoCResolveException: Failed to resolve type MvvmCross.ViewModels.IMvxAppStart
MvvmCross.IoC.MvxIoCContainer.Resolve(Type t)<a1ab21c493b64a15919bccd6a6fb7be2>:0
MvvmCross.IoC.MvxIoCContainer.Resolve<T>()<a1ab21c493b64a15919bccd6a6fb7be2>:0
MvvmCross.IoC.MvxIoCProvider.Resolve<T>()<a1ab21c493b64a15919bccd6a6fb7be2>:0
MvvmCross.Mvx.Resolve<TService>()<a1ab21c493b64a15919bccd6a6fb7be2>:0
MvvmCross.Platforms.Android.Views.MvxActivityViewExtensions.OnViewDestroy(IMvxAndroidView androidView)<a1ab21c493b64a15919bccd6a6fb7be2>:0
MvvmCross.Platforms.Android.Views.MvxActivityAdapter.EventSourceOnDestroyCalled(object sender, EventArgs eventArgs)<a1ab21c493b64a15919bccd6a6fb7be2>:0
at (wrapper delegate-invoke) <Module>.invoke_void_object_EventArgs(object,System.EventArgs)
MvvmCross.Base.MvxDelegateExtensions.Raise(EventHandler eventHandler, object sender)<a1ab21c493b64a15919bccd6a6fb7be2>:0
MvvmCross.Droid.Support.V7.AppCompat.EventSource.MvxEventSourceAppCompatActivity.OnDestroy()<a463012b56d64d1f9cc54a527e8dd780>:0
MvvmCross.Droid.Support.V7.AppCompat.MvxAppCompatActivity.OnDestroy()<a463012b56d64d1f9cc54a527e8dd780>:0
Android.App.Activity.n_OnDestroy(IntPtr jnienv, IntPtr native__this)<8e97598d39014e64a9b297bda6092daf>:0
at (wrapper dynamic-method) System.Object.51564007-77ee-4aca-b000-e0c439692f3c(intptr,intptr)
mvvmcross.droid.support.v7.appcompat.MvxAppCompatActivity.n_onDestroy(Native Method)
mvvmcross.droid.support.v7.appcompat.MvxAppCompatActivity.onDestroy()MvxAppCompatActivity.java:61
android.app.Activity.performDestroy()Activity.java:7462
android.app.Instrumentation.callActivityOnDestroy()Instrumentation.java:1255
android.app.ActivityThread.performDestroyActivity()ActivityThread.java:4590
android.app.ActivityThread.handleDestroyActivity()ActivityThread.java:4621
android.app.ActivityThread.-wrap5()Unknown Source:0
android.app.ActivityThread$H.handleMessage()ActivityThread.java:1757
android.os.Handler.dispatchMessage()Handler.java:105
android.os.Looper.loop()Looper.java:164
android.app.ActivityThread.main()ActivityThread.java:6938
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.Zygote$MethodAndArgsCaller.run()Zygote.java:327
com.android.internal.os.ZygoteInit.main()ZygoteInit.java:1374
public SplashScreen() : base(Resource.Layout.SplashScreen)
{
this.RegisterSetupType<Setup>();
}
protected override void RunAppStart(Bundle bundle)
{
var starter = MvvmCross.Mvx.Resolve<IMvxAppStart>();
starter.Start(model);
}
Version:
MvvmCross 6.0.0
Platform:
Android 5.1.1, 8.0.0
SAMSUNG SM-G5500
SAMSUNG SM-G950F
Hi, can you provide more info on how your application is setup. Are you registering your first view model in you App class?
Alternatively, can you reproduce this in the Playground sample apps?
@haohighview can you please follow up with more information so we can resolve this issue?
Sorry, I can't reproduce the bug. the bug information comes from hockeyapp.
public SplashScreen() : base(Resource.Layout.SplashScreen)
{
this.RegisterSetupType<Setup>();
}
protected override void RunAppStart(Bundle bundle)
{
try
{
string action = Intent.Action;
if (!string.IsNullOrEmpty(action))
{
if (action == Intent.ActionView)
{
Android.Net.Uri uri = Intent.Data;
if (uri == null)
return;
string[] param = uri.Path.Split('/');
model = new PCL.Models.ResetPasswordModel();
if (uri.Host.ToLower() == "resetpassword")
model.IsForgetPassword = true;
else
model.IsForgetPassword = false;
model.Email = param[1];
model.Codel = param[2];
model.IsFromLaunching = true;
}
}
}
catch (Exception) { }
var starter = MvvmCross.Mvx.Resolve<IMvxAppStart>();
if (!starter.IsStarted)
starter.Start(model);
}
public class Setup : MvxAppCompatSetup
{
public override MvxLogProviderType GetDefaultLogProviderType()
{
return MvxLogProviderType.Serilog;
}
protected override IMvxApplication CreateApp()
{
return new App();
}
protected override IMvxLogProvider CreateLogProvider()
{
Log.Logger = new LoggerConfiguration().MinimumLevel.Debug().WriteTo.AndroidLog().CreateLogger();
return base.CreateLogProvider();
}
protected override IMvxAndroidViewPresenter CreateViewPresenter()
{
return new MvxAppCompatViewPresenter(AndroidViewAssemblies);
}
protected override void InitializePlatformServices()
{
base.InitializePlatformServices();
Mvx.RegisterSingleton<IPlatformService>(new AndroidPlatformService());
}
}
@haohighview can you try overriding the OnDestroy in your activity that inherits from MvxAppCompatActivity and wrapping the call to the base method in a try catch.
Are you seeing this issue being reported a lot in HockeyApp, or was this a one off?
The only thing I can think of is that the user terminated the app before MvxSetup got a chance to be registered (eg they launched, then immediately closed the app)
@haohighview did you have any luck with this?
now, I can reproduce the bug. When the user just opened the app and is on the splash page, then click on the phone home button.
I overrode the OnDestroy and call to the base method in a try catch. Now I get another error.
android.util.SuperNotCalledException: Activity {com.boundlss.aisandroid/appboundlss.droid.SplashScreen} did not call through to super.onDestroy()
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4262)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4291)
at android.app.ActivityThread.-wrap7(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1649)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5975)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
@nickrandolph Do you have any update or need of further information?
@haohighview please create a sample where this is reproducible. I can't reproduce locally.
I created a sample but can't reproduce the issue.
Does this happen if you launch the app, and then press back button before the mainactivity has had a chance to display. I think what's happening is that it's attempting to destroy either the splash or mainactivity before the CurrentActivity has been correctly setup, thus causing this exception
yes, it happened launch the app, and then press back/home button before the mainactivity display
If that is the case @nickrandolph that means IMvxAppStart is not registered yet, right? Then there is technically no reason to call ResetStart() I guess.
So could the issue be solved by replacing Resolve for TryResolve here?
Yes, I think that should be sufficient to resolve this issue.
@haohighview would you be kind enough to raise a PR based on the suggestion made by @nmilcoff
@haohighview did you get around to raising a PR? If so, can you update it to reference this issue
I'll try and submit a PR later for this
I still encounter the same issue with MvvmCross version 6.2.0.
The crash occurred multiple times according AppCenter.
I also have this problem with 6.2.0. What's strange the app runs fine when deployed from USB but not when installed from apk
Edit:
Problem still exists in 6.2.1. The strange issue is that when built in Release mode with AOT and LLVM it works properly on Xiaomi (ABI v7a) but error occurs on Samsung S8 (ABI v8a).
Edit2:
It seems that the problem is related to archiving app into apk. When installed from .apk file from /bin/Release the problem doesn't occur on Samsung S8.
10-24 12:29:15.749 31713-31713/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: pl.myapp.app, PID: 31713
android.runtime.JavaProxyThrowable: MvvmCross.Exceptions.MvxIoCResolveException: Failed to resolve type MvvmCross.ViewModels.IMvxAppStart
at MvvmCross.IoC.MvxIoCContainer.Resolve (System.Type t) <0x770ac9efb8 + 0x000fc> in <8beeb96d9bc848278862c6e9b1d194c5>:0
at MvvmCross.IoC.MvxIoCContainer.Resolve[T] () <0x770ac9ef54 + 0x0002f> in <8beeb96d9bc848278862c6e9b1d194c5>:0
at MvvmCross.IoC.MvxIoCProvider.Resolve[T] () <0x770aca1fc8 + 0x0002f> in <8beeb96d9bc848278862c6e9b1d194c5>:0
at MvvmCross.Droid.Support.V7.AppCompat.MvxSplashScreenAppCompatActivity+<RunAppStartAsync>d__13.MoveNext () <0x7707849e2c + 0x00047> in <ca04e443302e44bd8f23c508ae467fd1>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x7709662e00 + 0x000e0> in <933519a6aacf4901b71c925c57500308>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x7709662d10 + 0x000df> in <933519a6aacf4901b71c925c57500308>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () <0x7709662ca4 + 0x0002f> in <933519a6aacf4901b71c925c57500308>:0
at MvvmCross.Droid.Support.V7.AppCompat.MvxSplashScreenAppCompatActivity+<InitializationComplete>d__12.MoveNext () <0x7707849cf0 + 0x000d7> in <ca04e443302e44bd8f23c508ae467fd1>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x7709662e00 + 0x000e0> in <933519a6aacf4901b71c925c57500308>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x7709662d10 + 0x000df> in <933519a6aacf4901b71c925c57500308>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () <0x7709662ca4 + 0x0002f> in <933519a6aacf4901b71c925c57500308>:0
at MvvmCross.Core.MvxSetupSingleton+<>c__DisplayClass13_0+<<StartSetupInitialization>b__1>d.MoveNext () <0x770aca8be0 + 0x000e3> in <8beeb96d9bc848278862c6e9b1d194c5>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x7709662e00 + 0x000e0> in <933519a6aacf4901b71c925c57500308>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x7709662d10 + 0x000df> in <933519a6aacf4901b71c925c57500308>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () <0x7709662ca4 + 0x0002f> in <933519a6aacf4901b71c925c57500308>:0
at MvvmCross.Base.MvxMainThreadAsyncDispatcher+<>c__DisplayClass1_0+<<ExecuteOnMainThreadAsync>b__0>d.MoveNext () <0x770ad14020 + 0x0014f> in <8beeb96d9bc848278862c6e9b1d194c5>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) <0x7709662980 + 0x00050> in <933519a6aacf4901b71c925c57500308>:0
at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () <0x770920f168 + 0x0001b> in <96e398f6131b46b6a81d87c3efb65f9f>:0
at Java.Lang.Thread+RunnableImplementor.Run () <0x770928e728 + 0x0002f> in <96e398f6131b46b6a81d87c3efb65f9f>:0
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) <0x77092874dc + 0x0004f> in <96e398f6131b46b6a81d87c3efb65f9f>:0
at (wrapper dynamic-method) System.Object.18(intptr,intptr)
at mono.java.lang.RunnableImplementor.n_run(Native Method)
at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
As I understand, SplashScreen uses Mvx.Resolve
c#
protected override void RunAppStart(Bundle bundle)
{
if (Mvx.TryResolve<IMvxAppStart>(out IMvxAppStart mvxAppStart))
{
if (mvxAppStart.IsStarted)
return;
mvxAppStart.Start(this.GetAppStartHint((object) bundle));
}
}
@NeuronKarrde would you mind opening a PR with these changes?
I haven't permission to push and create PR. How can I get them? Just change from at MvxSplashScreenAppCompatActivity and MvxSplashScreenActivity
```c#
protected virtual async Task RunAppStartAsync(Bundle bundle)
{
var startup = Mvx.IoCProvider.Resolve
if (!startup.IsStarted)
await startup.StartAsync(GetAppStartHint(bundle));
}
to
```c#
protected virtual async Task RunAppStartAsync(Bundle bundle)
{
if (Mvx.IoCProvider.TryResolve<IMvxAppStart>(out IMvxAppStart startup))
{
if (!startup.IsStarted)
await startup.StartAsync(GetAppStartHint(bundle));
}
}
Can anybody create this PR?
@NeuronKarrde fork the repository.
When is 6.2.3 planned to be released @martijn00 ?
@vallgrenerik soon 鈩笍
@Cheesebaron Okey! I reverted to 6.2.0 and it works.