0

I am newbie to Xamarin. I am trying to create application class as below code

[Application] 
class MyCustomApplicationClass : Application 
{ 
        public MyCustomApplicationClass (IntPtr handle, JniHandleOwnership ownerShip) : base (handle, ownerShip) 
        { 
        } 

        public override void OnCreate () 
        { 
                base.OnCreate(); 
                // add your custom stuff e.g. here... 
        } 
} 

It crashes app without MyCustomApplicationClass app is running perfectly fine.

Edited:-

Bug here Thanks in advance

Aditi
  • 455
  • 4
  • 13
  • By `It crashes app`, could you please show the error? Please edit your question. And [here is about custom Application](https://stackoverflow.com/questions/21427981/how-to-register-my-own-application-subclass-in-xamarin-android). BTW, your code works well for me, maybe there is another error. – Robbit Jan 04 '18 at 02:49
  • @JoeLv- I have edited post and added the bug screenshot – Aditi Jan 04 '18 at 06:12
  • Clean, rebuild, restart – Robbit Jan 04 '18 at 06:14
  • Is it a Xamarin.forms project? – Robbit Jan 04 '18 at 06:23
  • @JoeLv no Xamarin.Android Project – Aditi Jan 04 '18 at 06:55
  • Already Clean,Rebuild and Restart – Aditi Jan 04 '18 at 06:56
  • Xamarin.Android does not have an application class it is a concept of xamarin.forms – FreakyAli Jan 04 '18 at 07:41
  • I don't think your there is something wrong in your `MyCustomApplicationClass`, please remove bin/obj folder and try again, you can refer to [this](https://developer.xamarin.com/releases/android/xamarin.android_8/xamarin.android_8.1/#Known_Issues) – Robbit Jan 04 '18 at 09:22

1 Answers1

0

That error is often due to a conflict between support libraries and the version of Android sdk used. Check if the version is the same (everything 25.x, or everything 26.x, ...), restore packages, clean everything and launch.

Mauro Piccotti
  • 1,807
  • 2
  • 23
  • 34