Search code examples
androidandroid-intentxamarinandroid-camera

Android App crash after taking picture "Unable to find the default constructor" On LG 4G Stylus


My app crash after taking picture on LG 4G Stylus device. It's work fine on Galaxy nexus, Galaxy S4 , LG 4G.

I can't put the finger on it and it's driving me crazy...

I'm using a viewpager for my image and using theses manifest config :

<activity android:name="easydeal_android.MainActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="adjustPan|stateHidden">

I would really appreciate if someone can help me with this !

Here is the exception : Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.NotSupportedException: Unable to find the default constructor on type EasyDeal_Android.FragmentDetailsVehicle. Please provide the missing constructor. ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.

Here is the trace :

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
    ... 1 more
Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.NotSupportedException: Unable to find the default constructor on type EasyDeal_Android.FragmentDetailsVehicle.  Please provide the missing constructor. ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.
  --- End of managed exception stack trace ---
java.lang.Error: Java callstack:
    at mono.android.TypeManager.n_activate(Native Method)
    at mono.android.TypeManager.Activate(TypeManager.java:7)
    at md56d2061e530d4ae630a81127536162064.FragmentDetailsVehicle.<init>(FragmentDetailsVehicle.java:27)
    at java.lang.reflect.Constructor.newInstance(Native Method)
    at java.lang.Class.newInstance(Class.java:1572)
    at android.app.Fragment.instantiate(Fragment.java:611)
    at android.app.FragmentState.instantiate(Fragment.java:104)
    at android.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1775)
    at android.app.Activity.onCreate(Activity.java:946)
    at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:257)
    at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:58)
    at md56d2061e530d4ae630a81127536162064.MainActivity.n_onCreate(Native Method)
    at md56d2061e530d4ae630a81127536162064.MainActivity.onCreate(MainActivity.java:36)
    at android.app.Activity.performCreate(Activity.java:6021)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2405)
    at android.app.ActivityThread.access$800(ActivityThread.java:155)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1323)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5376)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
  --- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x00028>
at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue*) <0x000e7>
at Android.App.Activity.OnCreate (Android.OS.Bundle) <0x001cb>
at EasyDeal_Android.MainActivity.OnCreate (Android.OS.Bundle) <0x0001f>
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <0x0005b>
at (wrapper dynamic-method) object.1f7fe7fe-50ae-47b3-b6d7-d47312e8dfe6 (intptr,intptr,intptr) <0x00043>
    at md56d2061e530d4ae630a81127536162064.MainActivity.n_onCreate(Native Method)
    at md56d2061e530d4ae630a81127536162064.MainActivity.onCreate(MainActivity.java:36)
    at android.app.Activity.performCreate(Activity.java:6021)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2405)
    at android.app.ActivityThread.access$800(ActivityThread.java:155)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1323)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5376)
    ... 4 more

EDIT :

It did resolve the issue but it still crash with this line after taking more than one picture :

10-23 15:57:56.783   839  1707 I WindowState: WIN DEATH: Window{2380813b u0 adnt.easydeal/md56d2061e530d4ae630a81127536162064.MainActivity}
10-23 15:57:56.793   839  1682 I ActivityManager: Process adnt.easydeal (pid 2787) has died
10-23 15:57:56.793   839  1682 W ActivityManager: Force removing ActivityRecord{2e8c2d28 u0 adnt.easydeal/md56d2061e530d4ae630a81127536162064.MainActivity t2019}: app died, no saved state

Solution

  • Seems you got custom constructor in your FragmentDetailsVehicle class, but then you also need to hace the default c'tor (argument-less), which you gave to add to your Fragment class by hand. It must exist even if it does nothing:

    public FragmentDetailsVehicle() {}
    

    See: https://developer.android.com/reference/android/app/Fragment.html

    All subclasses of Fragment must include a public no-argument constructor. The framework will often re-instantiate a fragment class when needed, in particular during state restore, and needs to be able to find this constructor to instantiate it. If the no-argument constructor is not available, a runtime exception will occur in some cases during state restore.