I'm creating a simple android app that contains simple controls/views like Label, Entry and Buttons
- Target Framework: Android 8.1
- Target Android Version: Android 8.1
- Minimum Android Version: Android 4.4
After archive and generate APK file, i successfully installed it in my MEmu emulator (Android Version: 5.1). But when i tried to open it, the app crashes.
This is the error i get from device log tool:
System.NullReferenceException: Object reference not set to an instance of an object
at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.InternalSetPage (Xamarin.Forms.Page page) [0x0006f] in <99988d4ab8d144898ef5bc7586876d75>:0
at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.SetMainPage () [0x0000c] in <99988d4ab8d144898ef5bc7586876d75>:0
at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.LoadApplication (Xamarin.Forms.Application application) [0x0026f] in <99988d4ab8d144898ef5bc7586876d75>:0
at SampleApp.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00028] in <eaa39f9ef27d400ebfed424165f990c2>:0
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x0000f] in <818821ea7e204c78a45bc29cdc69e744>:0
at (wrapper dynamic-method) System.Object.fe8f1617-954f-4716-901a-433b7f8b44bf(intptr,intptr,intptr)
I suspect that this is Xamarin.Forms.Platform.Android.FormsAppCompatActivity
issue. Because when i changed the MainActivity parent class to Xamarin.Forms.Platform.Android.FormsApplicationActivity
it runs without error.
But how can i fix this error without switching to FormsApplicationActivity
??
Edit: When i disable ProGuard in the "Packaging Properties", the app runs smoothly. (why?)