Bug 35652 - AppCompat.FragmentContainer doesn't have a default contstructor
Summary: AppCompat.FragmentContainer doesn't have a default contstructor
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 1.5.1
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-11-07 07:45 UTC by Ahmed Hassan
Modified: 2015-11-12 18:45 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Ahmed Hassan 2015-11-07 07:45:13 UTC
AppCompat.FragmentContainer should have a public constructor the same way as the native counterpart:

https://developer.android.com/reference/android/app/FragmentContainer.html



How to reproduce:

- Use AppCompat
- Send app to the background
- Stop app process (I used Android Device Monitor)
- Start app

Full log:

11-07 07:32:21.182: I/MonoDroid(5109): UNHANDLED EXCEPTION:
11-07 07:32:21.182: I/MonoDroid(5109): System.NotSupportedException: Unable to find the default constructor on type Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.  Please provide the missing constructor. ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
11-07 07:32:21.182: I/MonoDroid(5109): Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.
11-07 07:32:21.182: I/MonoDroid(5109):   --- End of managed exception stack trace ---
11-07 07:32:21.182: I/MonoDroid(5109): java.lang.Error: Java callstack:
11-07 07:32:21.182: I/MonoDroid(5109): 	at mono.android.TypeManager.n_activate(Native Method)
11-07 07:32:21.182: I/MonoDroid(5109): 	at mono.android.TypeManager.Activate(TypeManager.java:7)
11-07 07:32:21.182: I/MonoDroid(5109): 	at md5eb25e0c6f853c9e5104b7654c9dc6cdf.FragmentContainer.<init>(FragmentContainer.java:24)
11-07 07:32:21.182: I/MonoDroid(5109): 	at java.lang.reflect.Constructor.newInstance(Native Method)
11-07 07:32:21.182: I/MonoDroid(5109): 	at java.lang.Class.newInstance(Class.java:1606)
11-07 07:32:21.182: I/MonoDroid(5109): 	at android.support.v4.app.Fragment.instantiate(Fragment.java:423)
11-07 07:32:21.183: I/MonoDroid(5109): 	at android.support.v4.app.FragmentState.instantiate(Fragment.java:102)
11-07 07:32:21.183: I/MonoDroid(5109): 	at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1907)
11-07 07:32:21.183: I/MonoDroid(5109): 	at android.support.v4.app.FragmentController.restoreAllState(FragmentController.java:135)
11-07 07:32:21.183: I/MonoDroid(5109): 	at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:251)
11-07 07:32:21.183: I/MonoDroid(5109): 	at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:61)
11-07 07:32:21.183: I/MonoDroid(5109): 	at md5788e426ffcaaf422eca676b505cd2c7a.MainActivity.n_onCreate(Native Method)
11-07 07:32:21.183: I/MonoDroid(5109): 	at md5788e426ffcaaf422eca676b505cd2c7a.MainActivity.onCreate(MainActivity.java:29)
11-07 07:32:21.183: I/MonoDroid(5109): 	at android.app.Activity.performCreate(Activity.java:5990)
11-07 07:32:21.183: I/MonoDroid(5109): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
11-07 07:32:21.183: I/MonoDroid(5109): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
11-07 07:32:21.183: I/MonoDroid(5109): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
11-07 07:32:21.183: I/MonoDroid(5109): 	at android.app.ActivityThread.access$800(ActivityThread.java:151)
11-07 07:32:21.183: I/MonoDroid(5109): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
11-07 07:32:21.183: I/MonoDroid(5109): 	at android.os.Handler.dispatchMessage(Handler.java:102)
11-07 07:32:21.183: I/MonoDroid(5109): 	at android.os.Looper.loop(Looper.java:135)
11-07 07:32:21.183: I/MonoDroid(5109): 	at android.app.ActivityThread.main(ActivityThread.java:5254)
11-07 07:32:21.183: I/MonoDroid(5109): 	at java.lang.reflect.Method.invoke(Native Method)
11-07 07:32:21.183: I/MonoDroid(5109): 	at java.lang.reflect.Method.invoke(Method.java:372)
11-07 07:32:21.183: I/MonoDroid(5109): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
11-07 07:32:21.183: I/MonoDroid(5109): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
11-07 07:32:21.183: I/MonoDroid(5109):   --- End of inner exception stack trace ---
11-07 07:32:21.183: I/MonoDroid(5109): at Java.Interop.TypeManager.n_Activate (intptr,intptr,intptr,intptr,intptr,intptr) <0x00257>
11-07 07:32:21.183: I/MonoDroid(5109): at (wrapper dynamic-method) object.bb30bd23-1c6f-4dc7-a74b-f0fc36ed192e (intptr,intptr,intptr,intptr,intptr,intptr) <0x0003b>
11-07 07:32:21.185: W/art(5109): JNI RegisterNativeMethods: attempt to register 0 native methods for md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable
11-07 07:32:21.187: I/MonoDroid(5109): UNHANDLED EXCEPTION:
11-07 07:32:21.187: I/MonoDroid(5109): System.NotSupportedException: Unable to find the default constructor on type Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.  Please provide the missing constructor. ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
11-07 07:32:21.187: I/MonoDroid(5109): Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.
11-07 07:32:21.187: I/MonoDroid(5109):   --- End of managed exception stack trace ---
11-07 07:32:21.187: I/MonoDroid(5109): java.lang.Error: Java callstack:
11-07 07:32:21.187: I/MonoDroid(5109): 	at mono.android.TypeManager.n_activate(Native Method)
11-07 07:32:21.187: I/MonoDroid(5109): 	at mono.android.TypeManager.Activate(TypeManager.java:7)
11-07 07:32:21.187: I/MonoDroid(5109): 	at md5eb25e0c6f853c9e5104b7654c9dc6cdf.FragmentContainer.<init>(FragmentContainer.java:24)
11-07 07:32:21.187: I/MonoDroid(5109): 	at java.lang.reflect.Constructor.newInstance(Native Method)
11-07 07:32:21.187: I/MonoDroid(5109): 	at java.lang.Class.newInstance(Class.java:1606)
11-07 07:32:21.187: I/MonoDroid(5109): 	at android.support.v4.app.Fragment.instantiate(Fragment.java:423)
11-07 07:32:21.187: I/MonoDroid(5109): 	at android.support.v4.app.FragmentState.instantiate(Fragment.java:102)
11-07 07:32:21.187: I/MonoDroid(5109): 	at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1907)
11-07 07:32:21.187: I/MonoDroid(5109): 	at android.support.v4.app.FragmentController.restoreAllState(FragmentController.java:135)
11-07 07:32:21.187: I/MonoDroid(5109): 	at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:251)
11-07 07:32:21.187: I/MonoDroid(5109): 	at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:61)
11-07 07:32:21.187: I/MonoDroid(5109): 	at md5788e426ffcaaf422eca676b505cd2c7a.MainActivity.n_onCreate(Native Method)
11-07 07:32:21.187: I/MonoDroid(5109): 	at md5788e426ffcaaf422eca676b505cd2c7a.MainActivity.onCreate(MainActivity.java:29)
11-07 07:32:21.187: I/MonoDroid(5109): 	at android.app.Activity.performCreate(Activity.java:5990)
11-07 07:32:21.187: I/MonoDroid(5109): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
11-07 07:32:21.187: I/MonoDroid(5109): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
11-07 07:32:21.187: I/MonoDroid(5109): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
11-07 07:32:21.187: I/MonoDroid(5109): 	at android.app.ActivityThread.access$800(ActivityThread.java:151)
11-07 07:32:21.187: I/MonoDroid(5109): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
11-07 07:32:21.187: I/MonoDroid(5109): 	at android.os.Handler.dispatchMessage(Handler.java:102)
11-07 07:32:21.187: I/MonoDroid(5109): 	at android.os.Looper.loop(Looper.java:135)
11-07 07:32:21.187: I/MonoDroid(5109): 	at android.app.ActivityThread.main(ActivityThread.java:5254)
11-07 07:32:21.187: I/MonoDroid(5109): 	at java.lang.reflect.Method.invoke(Native Method)
11-07 07:32:21.187: I/MonoDroid(5109): 	at java.lang.reflect.Method.invoke(Method.java:372)
11-07 07:32:21.187: I/MonoDroid(5109): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
11-07 07:32:21.187: I/MonoDroid(5109): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
11-07 07:32:21.187: I/MonoDroid(5109):   --- End of inner exception stack trace ---
11-07 07:32:21.187: I/MonoDroid(5109): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x00027>
11-07 07:32:21.187: I/MonoDroid(5109): at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue*) <0x000b3>
11-07 07:32:21.187: I/MonoDroid(5109): at Android.Support.V4.App.FragmentActivity.OnCreate (Android.OS.Bundle) <0x0014f>
11-07 07:32:21.187: I/MonoDroid(5109): at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnCreate (Android.OS.Bundle) <0x0001f>
11-07 07:32:21.187: I/MonoDroid(5109): at Boats.Droid.MainActivity.OnCreate (Android.OS.Bundle) <0x00063>
11-07 07:32:21.187: I/MonoDroid(5109): at Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <0x00057>
11-07 07:32:21.187: I/MonoDroid(5109): at (wrapper dynamic-method) object.ca8a1235-9bb3-407b-9c8e-f0211ea378a0 (intptr,intptr,intptr) <0x00027>
11-07 07:32:21.187: D/AndroidRuntime(5109): Shutting down VM
11-07 07:32:21.189: E/AndroidRuntime(5109): FATAL EXCEPTION: main
11-07 07:32:21.189: E/AndroidRuntime(5109): Process: com.SpaceMonkey.Boats, PID: 5109
11-07 07:32:21.189: E/AndroidRuntime(5109): java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
11-07 07:32:21.189: E/AndroidRuntime(5109): Caused by: java.lang.reflect.InvocationTargetException
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at java.lang.reflect.Method.invoke(Native Method)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at java.lang.reflect.Method.invoke(Method.java:372)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	... 1 more
11-07 07:32:21.189: E/AndroidRuntime(5109): Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.NotSupportedException: Unable to find the default constructor on type Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.  Please provide the missing constructor. ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
11-07 07:32:21.189: E/AndroidRuntime(5109): Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.
11-07 07:32:21.189: E/AndroidRuntime(5109):   --- End of managed exception stack trace ---
11-07 07:32:21.189: E/AndroidRuntime(5109): java.lang.Error: Java callstack:
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at mono.android.TypeManager.n_activate(Native Method)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at mono.android.TypeManager.Activate(TypeManager.java:7)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at md5eb25e0c6f853c9e5104b7654c9dc6cdf.FragmentContainer.<init>(FragmentContainer.java:24)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at java.lang.reflect.Constructor.newInstance(Native Method)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at java.lang.Class.newInstance(Class.java:1606)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.support.v4.app.Fragment.instantiate(Fragment.java:423)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.support.v4.app.FragmentState.instantiate(Fragment.java:102)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1907)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.support.v4.app.FragmentController.restoreAllState(FragmentController.java:135)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:251)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:61)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at md5788e426ffcaaf422eca676b505cd2c7a.MainActivity.n_onCreate(Native Method)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at md5788e426ffcaaf422eca676b505cd2c7a.MainActivity.onCreate(MainActivity.java:29)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.app.Activity.performCreate(Activity.java:5990)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.app.ActivityThread.access$800(ActivityThread.java:151)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.os.Handler.dispatchMessage(Handler.java:102)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.os.Looper.loop(Looper.java:135)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.app.ActivityThread.main(ActivityThread.java:5254)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at java.lang.reflect.Method.invoke(Native Method)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at java.lang.reflect.Method.invoke(Method.java:372)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
11-07 07:32:21.189: E/AndroidRuntime(5109):   --- End of inner exception stack trace ---
11-07 07:32:21.189: E/AndroidRuntime(5109): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x00027>
11-07 07:32:21.189: E/AndroidRuntime(5109): at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue*) <0x000b3>
11-07 07:32:21.189: E/AndroidRuntime(5109): at Android.Support.V4.App.FragmentActivity.OnCreate (Android.OS.Bundle) <0x0014f>
11-07 07:32:21.189: E/AndroidRuntime(5109): at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnCreate (Android.OS.Bundle) <0x0001f>
11-07 07:32:21.189: E/AndroidRuntime(5109): at Boats.Droid.MainActivity.OnCreate (Android.OS.Bundle) <0x00063>
11-07 07:32:21.189: E/AndroidRuntime(5109): at Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <0x00057>
11-07 07:32:21.189: E/AndroidRuntime(5109): at (wrapper dynamic-method) object.ca8a1235-9bb3-407b-9c8e-f0211ea378a0 (intptr,intptr,intptr) <0x00027>
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at md5788e426ffcaaf422eca676b505cd2c7a.MainActivity.n_onCreate(Native Method)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at md5788e426ffcaaf422eca676b505cd2c7a.MainActivity.onCreate(MainActivity.java:29)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.app.Activity.performCreate(Activity.java:5990)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.app.ActivityThread.access$800(ActivityThread.java:151)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
11-07 07:32:21.189: E/AndroidRuntime(5109): 	at a
Comment 1 Jonathan Pryor 2015-11-11 15:18:11 UTC
Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer != Android.App.FragmentContainer. These are different types.
Comment 2 Ahmed Hassan 2015-11-11 15:43:40 UTC
I know that. I don't understand your point.

The AppCompat native Android type:

https://developer.android.com/reference/android/support/v4/app/FragmentContainer.html

has a default public constructor as well.

Also, the main problem remains, that an app will crash when restarted giving that exception I've provided which happens because that type is missing a default public constructor.
Comment 3 Ahmed Hassan 2015-11-12 18:45:41 UTC
This has been fixed in pre2, but there is a new bug:
https://bugzilla.xamarin.com/show_bug.cgi?id=35824