Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InstantiationException: can't instantiate class com.tripvi.drawerlayout.Drawer$ContentWrapperFragment #22

Open
manumaticx opened this issue Jun 24, 2014 · 4 comments

Comments

@manumaticx
Copy link
Contributor

Sometimes, my app is crashing on resume.

06-24 13:15:41.897: E/AndroidRuntime(17536): FATAL EXCEPTION: main
06-24 13:15:41.897: E/AndroidRuntime(17536): Process: com.goyya.fde, PID: 17536
06-24 13:15:41.897: E/AndroidRuntime(17536): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.goyya.fde/org.appcelerator.titanium.TiActivity}: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.tripvi.drawerlayout.Drawer$ContentWrapperFragment: make sure class name exists, is public, and has an empty constructor that is public
06-24 13:15:41.897: E/AndroidRuntime(17536):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at android.app.ActivityThread.access$800(ActivityThread.java:135)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at android.os.Handler.dispatchMessage(Handler.java:102)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at android.os.Looper.loop(Looper.java:136)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at android.app.ActivityThread.main(ActivityThread.java:5001)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at java.lang.reflect.Method.invokeNative(Native Method)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at java.lang.reflect.Method.invoke(Method.java:515)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at dalvik.system.NativeStart.main(Native Method)
06-24 13:15:41.897: E/AndroidRuntime(17536): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.tripvi.drawerlayout.Drawer$ContentWrapperFragment: make sure class name exists, is public, and has an empty constructor that is public
06-24 13:15:41.897: E/AndroidRuntime(17536):    at android.support.v4.app.Fragment.instantiate(Fragment.java:413)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at android.support.v4.app.FragmentState.instantiate(Fragment.java:97)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1801)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:213)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:97)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:472)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at android.app.Activity.performCreate(Activity.java:5231)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
06-24 13:15:41.897: E/AndroidRuntime(17536):    ... 11 more
06-24 13:15:41.897: E/AndroidRuntime(17536): Caused by: java.lang.InstantiationException: can't instantiate class com.tripvi.drawerlayout.Drawer$ContentWrapperFragment; no empty constructor
06-24 13:15:41.897: E/AndroidRuntime(17536):    at java.lang.Class.newInstanceImpl(Native Method)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at java.lang.Class.newInstance(Class.java:1208)
06-24 13:15:41.897: E/AndroidRuntime(17536):    at android.support.v4.app.Fragment.instantiate(Fragment.java:402)
06-24 13:15:41.897: E/AndroidRuntime(17536):    ... 20 more

It's hard to reproduce: when I'm leaving the App with back button or home button and open it again immediately everything works fine. But if I wait some time after sending it to background it crashes with the above exception on resuming and restarts. Do you have any idea what could be the reason?

(Testing on Nexus 5 with 4.4.3 on Titanium SDK 3.3.0)

@manumaticx
Copy link
Contributor Author

Steps to reproduce:

  • open app
  • press home button
  • wait for about 20 minutes
  • open app again
  • should crash with the above exception

I'm working on a fix. PR is in the making.

manumaticx referenced this issue in manumaticx/Ti.DrawerLayout Jun 25, 2014
contentView is not passed through contructor anymore. It is instead set via method.
Fixes #22
@sakae-nakajima
Copy link

Any progress on this, I am having the same problem. This is easy to reproduce.

  • Close my app
  • Open memory hungry apps like FB
  • Open my app

Black screen with the exception mentioned in the original post.

@manumaticx
Copy link
Contributor Author

As mentioned above, I fixed this. Not sure why my pull requests aren't merged.

But you can grab an updated version of the module in my fork: https://github.com/manumaticx/Ti.DrawerLayout

It's streets ahead of this one.

@sakae-nakajima
Copy link

Thank you very much, I noticed it and I am giving a shot now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants