Android 拍照后应用程序崩溃 "Unable to find the default constructor" 在 LG 4G Stylus 上

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

我的应用程序在 LG 4G Stylus 设备上拍照后崩溃。 它在 Galaxy nexus、Galaxy S4、LG 4G 上运行良好。

我不能把手指放在上面,这让我发疯...

我正在为我的图像使用 viewpager 并使用这些清单配置:

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

如果有人能帮助我,我将不胜感激!

这里是例外: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.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.access0(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.access0(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

编辑:

它确实解决了问题,但在拍了不止一张照片后它仍然崩溃了:

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

您的 FragmentDetailsVehicle class 中似乎有自定义构造函数,但您还需要手动添加默认构造函数,即使它实际上什么都不做:

public FragmentDetailsVehicle() {}

参见: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.