urho
urho copied to clipboard
SimpleApplication as a new Activity issue
@migueldeicaza @radical @bratsche @krukow @duncanmak @vancura @EgorBo
Hi!
Assume the below call from Android application's OnCreate( ) method:
UrhoSurface.RunInActivity<MyApplication>(new ApplicationOptions("Data"));
Where MyApplication is defined following way:
internal class MyApplication : Urho.SimpleApplication
{
public MyApplication(ApplicationOptions options) : base(options)
{
// init the app here
}
}
The above causes following runtime exception:
04-11 15:45:27.218 E/mono (13551): Unhandled Exception: 04-11 15:45:27.218 E/mono (13551): System.InvalidOperationException: Constructor UrhoSimpleAppTest.MyApplication(ApplicationOptions) was not found. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object 04-11 15:45:27.218 E/mono (13551): at UrhoSimpleAppTest.MyApplication..ctor (Urho.ApplicationOptions options) [0x00021] in <5ee0f63751a64f7caa83b58be11f38bd>:0 04-11 15:45:27.218 E/mono (13551): at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&) 04-11 15:45:27.218 E/mono (13551): at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <18c1141d09344a2181b99b2eb1cd50b6>:0 04-11 15:45:27.218 E/mono (13551): --- End of inner exception stack trace --- 04-11 15:45:27.218 E/mono (13551): at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00017] in <18c1141d09344a2181b99b2eb1cd50b6>:0 04-11 15:45:27.218 E/mono (13551): at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0007a] in <18c1141d09344a2181b99b2eb1cd50b6>:0 04-11 15:45:27.218 E/mono (13551): at System.Reflection.MonoCMethod.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <18c1141d09344a2181b99b2eb1cd50b6>:0 04-11 15:45:27.218 E/mono (13551): at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x00213] in <18c1141d09344a2181b99b2eb1cd50b6>:0 04-11 15:45:27.218 E/mono (13551): at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x00095] in <18c1141d09344a2181b99b2eb1cd50b6>:0 04-11 15:45:27.218 E/mono (13551): at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in <18c1141d09344a2181b99b2eb1cd50b6>:0 04-11 15:45:27.218 E/mono (13551): at Urho.Application.CreateInstance (System.Type applicationType, Urho.ApplicationOptions options) [0x00000] in <965326e0f5c24b1cb5201899a33f6f26>:0 04-11 15:45:27.218 E/mono (13551): --- End of inner exception stack trace ---
Any idea why it doesn't work?
The documentation says:
The simplest way to run a game, as implemented in the MyGame class is to call
UrhoSurface.RunInActivity<MyGame>();
BR,
Ladislav
@migueldeicaza
Maybe an override for Urho.Droid.UrhoSurface.RunInActivity with support for Urho.SimpleApplication is missing?