Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Crash reports caused by android.app.Fragment$InstantiationException

Discussion in 'Android' started by Tx, May 24, 2017.

  1. Tx

    Tx

    Joined:
    Jul 4, 2012
    Posts:
    108
    Hi to all,
    Lately I'm checking the issues that our game has on several android devices and I'm checking all the data reported by Android Vitals in the Google Play Console.

    I found that a lot of crashes were due to a java.lang.RuntimeException and Caused by: android.app.Fragment$InstantiationException:
    this is a sample of what the data looks like.

    java.lang.RuntimeException:
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2440)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2500)
    at android.app.ActivityThread.access$900(ActivityThread.java:163)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1362)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5585)
    at java.lang.reflect.Method.invoke(Native Method:0)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
    Caused by: android.app.Fragment$InstantiationException:
    at android.app.Fragment.instantiate(Fragment.java:628)
    at android.app.FragmentState.instantiate(Fragment.java:106)
    at android.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1858)
    at android.app.FragmentController.restoreAllState(FragmentController.java:122)
    at android.app.Activity.onCreate(Activity.java:919)
    at com.unity3d.player.UnityPlayerActivity.onCreate(Unknown Source:0)
    at com.unity3d.player.UnityPlayerNativeActivity.onCreate(Unknown Source:0)
    at android.app.Activity.performCreate(Activity.java:6279)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2393)

    The version of Unity3D is 5.6.0f3 and all the crashes (so far) are on Android 6.0 devices.
    Supported OpenGL Version reported by Internals goes from OpenGL ES 2.0 to ES 3.1.

    Unfortunately:
    1. I do not experience crashes on the devices I use for testing so I haven't a logcat or can't replicate the bug.
    2. I'm not expert of Unity3D internals so I do not know what I may do wrong. Seems it's a crash during the startup phase. Seems it is 'fragment' creation but what can I check to pinpoint the problem? I don't see any common factor in the 100+ crash reports (all RuntimeException in Fragment$InstantiationException).

    What can I do to solve a bug like this?
     
    Last edited: May 24, 2017
  2. Tx

    Tx

    Joined:
    Jul 4, 2012
    Posts:
    108
    No one has any idea?
    What I'm supposed to do? Update Unity version and pray?
     
  3. Tartle-Games

    Tartle-Games

    Joined:
    Feb 8, 2016
    Posts:
    1
    I saw a crash with one of my apps reported on the Google Play Console with this same exception reported. It is an older app of mine built with Unity 4.6 and I have never seen a crash reported until now. Therefore, I am thinking this is not a straightforward update-Unity problem but something specific to a device or an Android version. I have no solution but I wanted to provide my info

    crash occurred on: Android 7.0
    Device: Galaxy Note5 (noblelte)
    Native platform armeabi-v7a
    OpenGL ES version 3.1
    CPU make Samsung
    CPU model Exynos 7420

    Here is my exception log that the Google Play console provided me:


    java.lang.RuntimeException:
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)
    at android.app.ActivityThread.-wrap14(ActivityThread.java:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6682)
    at java.lang.reflect.Method.invoke(Native Method:0)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
    Caused by: android.app.Fragment$InstantiationException:
    at android.app.Fragment.instantiate(Fragment.java:637)
    at android.app.FragmentState.instantiate(Fragment.java:111)
    at android.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1946)
    at android.app.FragmentController.restoreAllState(FragmentController.java:136)
    at android.app.Activity.onCreate(Activity.java:1037)
    at android.app.NativeActivity.onCreate(NativeActivity.java:185)
    at com.unity3d.player.UnityPlayerNativeActivity.onCreate(Unknown Source:0)
    at android.app.Activity.performCreate(Activity.java:6942)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2880)
     
  4. neonxu

    neonxu

    Joined:
    Nov 2, 2016
    Posts:
    12
    Any solution? It's same here +1.
    We use unity3d 5.6.1p2, crash on Android 6.0 devices.

    Galaxy J7(2016) (j7xelte) 27 5.5%
    Galaxy J5 Prime (on5xelte) 26 5.3%
    Galaxy J2 Prime (grandpplte) 25 5.1%
    Galaxy J7 (j7elte) 20 4.1%
    Other 389 79.9%

    java.lang.RuntimeException:
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
    at android.app.ActivityThread.access$900(ActivityThread.java:150)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method:0)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    Caused by: android.app.Fragment$InstantiationException:
    at android.app.Fragment.instantiate(Fragment.java:628)
    at android.app.FragmentState.instantiate(Fragment.java:106)
    at android.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1858)
    at android.app.FragmentController.restoreAllState(FragmentController.java:122)
    at android.app.Activity.onCreate(Activity.java:923)
    at com.unity3d.player.UnityPlayerActivity.onCreate(Unknown Source:0)
    at com.atom.utils.atomapp.AtomAppUtil.onCreate(AtomAppUtil.java:91)
    at android.app.Activity.performCreate(Activity.java:6285)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
     
  5. neonxu

    neonxu

    Joined:
    Nov 2, 2016
    Posts:
    12
    any update?
     
  6. acoolaum

    acoolaum

    Joined:
    Nov 14, 2014
    Posts:
    4
    We have got the same problem on wide rangle Android 6.0 devices:

    java.lang.RuntimeException:
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3319)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
    at android.app.ActivityThread.access$1100(ActivityThread.java:229)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:7325)
    at java.lang.reflect.Method.invoke(Native Method:0)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
    Caused by: android.app.Fragment$InstantiationException:
    at android.app.Fragment.instantiate(Fragment.java:642)
    at android.app.FragmentState.instantiate(Fragment.java:114)
    at android.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1880)
    at android.app.FragmentController.restoreAllState(FragmentController.java:123)
    at android.app.Activity.onCreate(Activity.java:1048)
    at com.unity3d.player.UnityPlayerActivity.onCreate(Unknown Source:0)
    at android.app.Activity.performCreate(Activity.java:6904)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)

    Do you use plugins in your application?
     
  7. Mathijs333

    Mathijs333

    Joined:
    May 20, 2014
    Posts:
    15
    Hi,

    Anyone an update?

    Same here. Android 6.0 only. Wide range of devices.

    We are using Chartboost, Applovin, Google Mobile ads and a few other like UTNOtificationmanager and some of our own plugings.

    I've seen it happening. It is during the start of the app. The good news is that it doesn't really crash the app, although google play tells us so. But... as we all know google provides information with a reason. Therefore we try to minimize the number of crashes, as it probably is, a minor, factor for ranking.


    java.lang.RuntimeException:
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2423)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483)
    at android.app.ActivityThread.access$900(ActivityThread.java:157)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5476)
    at java.lang.reflect.Method.invoke(Native Method:0)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    Caused by: android.app.Fragment$InstantiationException:
    at android.app.Fragment.instantiate(Fragment.java:628)
    at android.app.FragmentState.instantiate(Fragment.java:106)
    at android.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1858)
    at android.app.FragmentController.restoreAllState(FragmentController.java:122)
    at android.app.Activity.onCreate(Activity.java:923)
    at com.unity3d.player.UnityPlayerActivity.onCreate(Unknown Source:0)
    at android.app.Activity.performCreate(Activity.java:6285)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376)
     
  8. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    I am seeing the same "Caused by: android.app.Fragment$InstantiationException:" crash the last weeks increasing.

    Build using unity 4.7.1
     
  9. acoolaum

    acoolaum

    Joined:
    Nov 14, 2014
    Posts:
    4
    We have received same crash reports on Android 7.0 at this week:

    java.lang.RuntimeException:
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
    at android.app.ActivityThread.-wrap12(ActivityThread.java:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:159)
    at android.app.ActivityThread.main(ActivityThread.java:6097)
    at java.lang.reflect.Method.invoke(Native Method:0)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
    Caused by: android.app.Fragment$InstantiationException:
    at android.app.Fragment.instantiate(Fragment.java:637)
    at android.app.FragmentState.instantiate(Fragment.java:111)
    at android.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1942)
    at android.app.FragmentController.restoreAllState(FragmentController.java:135)
    at android.app.Activity.onCreate(Activity.java:982)
    at com.unity3d.player.UnityPlayerActivity.onCreate(Unknown Source:0)
    at android.app.Activity.performCreate(Activity.java:6743)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
     
  10. CybIam

    CybIam

    Joined:
    Nov 6, 2016
    Posts:
    57
    I've already asked this question on SO.

    Exception occurs when the UnityPlayer creates its main activity. This could happen if the game was just started, or if the user switches between apps and then goes back to the game (for example tapped on advertisement, goes to the PlayMarket and then goes back). I am using 3rd party advertisement engine from Appodeal. Recently I contacted them and asked about this exception pointing out to native plugins for different ad networks. They did some research and told me that they found no connection with native plugins.

    This exception shows that onCreate method of activity class is called with non null parameter savedInstanceState. That's why android trying reinitialize fragments from the saved states.
    According to the docs:
    From the source code:
    Code (CSharp):
    1. if (savedInstanceState != null) {
    2.             Parcelable p = savedInstanceState.getParcelable(FRAGMENTS_TAG);
    3.             mFragments.restoreAllState(p, mLastNonConfigurationInstances != null
    4.                     ? mLastNonConfigurationInstances.fragments : null);
    5.         }
    All my users are suffer on Android 6 devices. All apk builds are made up with Unity 5.5.03f. I have several devices with Android 6 and I cannot reproduce this crush/error on any of them.
     
  11. neonxu

    neonxu

    Joined:
    Nov 2, 2016
    Posts:
    12
    This is really frustrating bug.
     
  12. CybIam

    CybIam

    Joined:
    Nov 6, 2016
    Posts:
    57
    Finally! I am able to reproduce this error! And as I thought from the beginning this is about permissions, sort of :)

    On the modern devices user being asked about runtime permissions. UnityPlayer at startup checks for permissions and displays dialog for each of them. Unity Player has a class which subclassed from Fragment for this purposes.

    Fragment:
    According to the docs:
    InstantiationException:
    According to the docs:
    UnityPlayer:
    From the decompiled source code of UnityPlayer:
    Code (JavaScript):
    1.  
    2. final class d$1
    3.   extends Fragment
    4. {
    5.   d$1(d paramd, List paramList, FragmentManager paramFragmentManager, Runnable paramRunnable) {}
    6.   // Other code is skipped for readability ...
    7. }
    8.  
    As you can see there is just one constructor WITH parameters.

    To reproduce this error you have to kill and restore activity while there is a dialog box asking for granting permission. I dont know why players do such things, may be they switch to another app and come back later when OS already killed game thread and trying to recreate it again with saved state for last visible fragment.

    Anyway, according to Google documentation UnityPlayer has incorrect implementation of subclassed Fragment class. I understand this is rare situation, but still it has to be fixed somehow.
     
  13. MigrantP

    MigrantP

    Joined:
    Jun 24, 2013
    Posts:
    118
    We have a couple of these in the Play Store crash report as well.
     
  14. neonxu

    neonxu

    Joined:
    Nov 2, 2016
    Posts:
    12
    Has anyone submitted the bug to Unity Issue Tracker?
     
  15. LunarExGames

    LunarExGames

    Joined:
    Feb 18, 2015
    Posts:
    44
    Receiving a lot of these crashes in my Google Play Store - though I can't seem to replicate on my own tests.

    java.lang.RuntimeException
    :

    at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3256)

    at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3352)

    at android.app.ActivityThread.access$1100 (ActivityThread.java:223)

    at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1797)

    at android.os.Handler.dispatchMessage (Handler.java:102)

    at android.os.Looper.loop (Looper.java:158)

    at android.app.ActivityThread.main (ActivityThread.java:7231)

    at java.lang.reflect.Method.invoke (Native Method)

    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)

    at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
    Caused by: android.app.Fragment$InstantiationException:

    at android.app.Fragment.instantiate (Fragment.java:642)

    at android.app.FragmentState.instantiate (Fragment.java:114)

    at android.app.FragmentManagerImpl.restoreAllState (FragmentManager.java:1880)

    at android.app.FragmentController.restoreAllState (FragmentController.java:123)

    at android.app.Activity.onCreate (Activity.java:1036)

    at com.unity3d.player.UnityPlayerActivity.onCreate (Unknown Source)

    at android.app.Activity.performCreate (Activity.java:6877)

    at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1136)

    at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3209)

    Could this have something to do with Everyplay - as it started to happen after installing that?
     
  16. CybIam

    CybIam

    Joined:
    Nov 6, 2016
    Posts:
    57
    I did. But unfortunately the guys from Unity cannot reproduce it on they own.

    Can someone post devices names from the crash logs?
    I've sent some names to QA team but they want more ...
     
  17. kapyar

    kapyar

    Joined:
    Dec 13, 2014
    Posts:
    8
    Here is the list from google play console for my game:

    Zmax Pro (urd)
    Galaxy J7 (j7e3g)
    Redmi Note 4 (nikel)
    LG K10 LTE (m253)
    Galaxy J5 (j5lte)
    Galaxy Tab E 8.0 (gtesltevzw)
    LG G Stylo (g4stylusc)

    All running Android 6
     
  18. CybIam

    CybIam

    Joined:
    Nov 6, 2016
    Posts:
    57
    Thanks.
     
  19. CybIam

    CybIam

    Joined:
    Nov 6, 2016
    Posts:
    57
    A little bit of updates:

    1. I haven't heard from Unity QA team for a while, so I think they won't do anything.
    2. I have tested my concerns about incorrect implementation of Fragment and it worked. Besides of empty constructor I have made some other corrections to d$1 class - so far fragment instantiation goes well without crashes.

    The main question is still open - why dont they fix it? It is quite simple.
     
  20. GastonC

    GastonC

    Joined:
    Aug 26, 2012
    Posts:
    38
    Hi there!

    Can you please upload the files you modified, so we can also take a look and try it out? Still crash free on this?

    Thanks!
     
  21. CybIam

    CybIam

    Joined:
    Nov 6, 2016
    Posts:
    57
    I dont think it will be appropriate since it is a patch to private UnityPlayer code. I did it just to get the proof of concept.
     
  22. CybIam

    CybIam

    Joined:
    Nov 6, 2016
    Posts:
    57
    From now on I see this situation as a bit larger problem because every saved fragment will be shown at UnityPlayer startup. We can disable Unity permission handler by modifying manifest and implement runtime permission handler by ourself. But if game will be stopped by Android and later resumed by player all saved fragments will be shown at startup since all fragments are attached to UnityPlayerActivity.

    As I see it there is only way to control this:
    1. Disable Unity permission handler in manifest.
    2. Implement own permission manager.
    3. Subclass new activity from UnityPlayerActivity and override onSaveInstanceState.
    4. Modify manifest to launch new subclassed activity.

    Any ideas would be appreciated :)
     
    Last edited: Sep 1, 2017
  23. CybIam

    CybIam

    Joined:
    Nov 6, 2016
    Posts:
    57
    I've implemented 2nd approach and it works. Except onSaveInstanceState override since it is useless. As far as I see there is no way to hide fragment before app goes to background, so at the game startup all saved fragments will be shown anyway.

    If someone know how to hide fragments before onPause event I will be gratefull.
     
  24. flyffol

    flyffol

    Joined:
    Feb 27, 2017
    Posts:
    4
    @Cyblam
    Can you post your reproduce method.
    Our QC need reproduce this bug.
     
  25. CybIam

    CybIam

    Joined:
    Nov 6, 2016
    Posts:
    57

    see my post above
     
  26. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    Is there a bug report? I remember something related to that.
     
  27. CybIam

    CybIam

    Joined:
    Nov 6, 2016
    Posts:
    57
    Yep. Case 934782.
     
  28. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    Yeah this one is being processed. However it does not seem to be reproducible. The Galaxy S3 has a non-OEM ROM so it's not supported.

    Also, the exception logged when you kill an activity after being paused during the permissions dialog - is not a crash, and is unlikely to be fixed.

    I'll look into implementing this Fragment better... but a reproducible crash will make me do it much faster.
     
  29. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    Our QAs tried pausing and resuming the app during the permission popup on several devices, using all Unity versions - no crash so far.

     
  30. CybIam

    CybIam

    Joined:
    Nov 6, 2016
    Posts:
    57
    It is a real crash, app is stopped and report being sent.
    Ok, once again :)

    1. Invalid fragment implementation - no-argument constructor is missing, and as far as I remember this class is private but must be public.

    2. Fragment is attached to UnityPlayerActivity, so obviously when activity goes to background the state of fragments are saved.

    3. As I mention before this is a rare situation - you have to have permission dialog on the screen, put app to background and kill app(with ddms for example).

    4. When you restart app the first thing you see is a thumbnail of app. To get the crash simply select "grant" or "deny" and the app will be closed by the system because it will try to instantiate saved fragment wich has no default constructor.

    5. This has to be reproduceable on every device on Android 6.0 and up.

    6. And of course the fast way is to check up the source code for UnityPlayerActivity :)
     
    Last edited: Sep 18, 2017
  31. CybIam

    CybIam

    Joined:
    Nov 6, 2016
    Posts:
    57
    onPause and onResume events are handled fine because there is no fragment instantiations! You can check logs attached to the case. This error can happen only on onCreate event when app is restarting using last saved state.
     
  32. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    @CybIam thanks for the detailed info! We'll try to get this sorted.
     
  33. afeilo

    afeilo

    Joined:
    Sep 20, 2017
    Posts:
    1
    Last edited: Sep 20, 2017
  34. 3gogames

    3gogames

    Joined:
    Jul 28, 2015
    Posts:
    31
    After our game release, we have registered a lot of crashes like these (using Crashlytics):

    Fatal Exception: java.lang.RuntimeException
    Unable to start activity ComponentInfo{com.reludo.shootingrangechallenge/com.unity3d.player.UnityPlayerActivity}: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.unity3d.player.f$1: make sure class name exists, is public, and has an empty constructor that is public

    Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.reludo.shootingrangechallenge/com.unity3d.player.UnityPlayerActivity}: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.unity3d.player.f$1: make sure class name exists, is public, and has an empty constructor that is public
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2426)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
    at android.app.ActivityThread.-wrap11(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5443)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    Caused by android.app.Fragment$InstantiationException: Unable to instantiate fragment com.unity3d.player.f$1: make sure class name exists, is public, and has an empty constructor that is public
    at android.app.Fragment.instantiate(Fragment.java:628)
    at android.app.FragmentState.instantiate(Fragment.java:106)
    at android.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1860)
    at android.app.FragmentController.restoreAllState(FragmentController.java:122)
    at android.app.Activity.onCreate(Activity.java:918)
    at com.unity3d.player.UnityPlayerActivity.onCreate(Unknown Source)
    at android.app.Activity.performCreate(Activity.java:6245)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
    at android.app.ActivityThread.-wrap11(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5443)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    Caused by java.lang.IllegalAccessException: java.lang.Class<com.unity3d.player.f$1> is not accessible from java.lang.Class<android.app.Fragment>
    at java.lang.Class.newInstance(Class.java)
    at android.app.Fragment.instantiate(Fragment.java:613)
    at android.app.FragmentState.instantiate(Fragment.java:106)
    at android.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1860)
    at android.app.FragmentController.restoreAllState(FragmentController.java:122)
    at android.app.Activity.onCreate(Activity.java:918)
    at com.unity3d.player.UnityPlayerActivity.onCreate(Unknown Source)
    at android.app.Activity.performCreate(Activity.java:6245)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
    at android.app.ActivityThread.-wrap11(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5443)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

    Is there any solution?

    Thanks
     
  35. CybIam

    CybIam

    Joined:
    Nov 6, 2016
    Posts:
    57
    1. Disable Unity permission handler in manifest:
    2. Implement your own permission manager in java. You can google a lot of working examples.

    Unity team still has not confirm this as a bug ...
     
  36. uspdev

    uspdev

    Joined:
    Sep 29, 2016
    Posts:
    5
    how to fix this... my crash increase... :(
     
  37. fourdesire

    fourdesire

    Joined:
    Sep 26, 2014
    Posts:
    17
    We had this issue and solved after taking some time to research. This is easy to produce:

    You have to enable unity player auto permission dialog first (this feature is enabled by default)
    <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="false" />

    1. Then we open the app and wait for the permission dialog shown and remain the dialog there (do not press any buttons)
    2. Then we go back to home, let your app go to background.
    3. Reopen it. (it happens here)

    This is because Activity want to recover the dialog from saved state. However the class is a internal class. So they cannot directly generate it from name.

    Solution:

    Go to your main activity that holds unityplayeractivity, and pass null to super.onCreate(). Then it will not generate the dialog anymore.


    Code (CSharp):
    1.  
    2. public class YourActivity extends UnityPlayerActivity {
    3.  
    4. @Override
    5. protected void onCreate(Bundle context) {
    6.    super.onCreate(null); // Pass null to prevent fragment exception of permission request by unity
    7.  .....
    8. }
     
  38. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    @fourdesire it's not reproducible this way, according to our QAs.
     
  39. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    The fix is coming.

    From what we see, it affects Android 6 devices. Never had the issue by pausing or swiping away the app from recents. Two ways to reproduce it:
    - kill the app from DDMS - not a valid use case as "the app may misbehave" <= this is the system message for force stop.
    - "Do not keep activities" turned on.

    Anyway - the fix is coming! We are planning to backport it up to 5.6.
     
  40. fourdesire

    fourdesire

    Joined:
    Sep 26, 2014
    Posts:
    17
  41. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    We are not planning to backport this fix to 5.5 because it's really minor.
     
  42. 3gogames

    3gogames

    Joined:
    Jul 28, 2015
    Posts:
    31
    Thank you @Yury-Habets! May I ask you when have you planned the release for 5.6?

    Thank you again for your support.
     
  43. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    835
    This will be fixed in 5.6.4p3.
     
  44. 3gogames

    3gogames

    Joined:
    Jul 28, 2015
    Posts:
    31
    Great!
    Is there already a date for 5.6.4p3 release?
     
  45. Babybus_Study

    Babybus_Study

    Joined:
    Oct 31, 2016
    Posts:
    14
    happy to see this problem is going to be fixed. way to go guys!
     
  46. abcom

    abcom

    Joined:
    Nov 20, 2017
    Posts:
    2
    at com.sdkbox.plugin.SDKBox.nOnActivityResult (Native Method)
    at com.sdkbox.plugin.SDKBox$6.run (SDKBox.java:167)
    at com.sdkbox.plugin.SDKBox.runOnMainThread (SDKBox.java:255)
    at com.sdkbox.plugin.SDKBox.runOnGLThread (SDKBox.java:244)
    at com.sdkbox.plugin.SDKBox.onActivityResult (SDKBox.java:165)
    at com.sdkbox.activity.CustomActivity.onActivityResult (CustomActivity.java:18)
    at android.app.Activity.dispatchActivityResult (Activity.java:6442)
    at android.app.ActivityThread.deliverResults (ActivityThread.java:3716)
    at android.app.ActivityThread.handleSendResult (ActivityThread.java:3763)
    at android.app.ActivityThread.-wrap16 (ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1403)
    at android.os.Handler.dispatchMessage (Handler.java:102)
    at android.os.Looper.loop (Looper.java:148)
    at android.app.ActivityThread.main (ActivityThread.java:5443)
    at java.lang.reflect.Method.invoke (Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:72
     
  47. gulfam131

    gulfam131

    Joined:
    Aug 1, 2013
    Posts:
    10
    @JuliusM Are you solving in Unity 2017 also?
    These are too many crashes in our games:

    java.lang.RuntimeException
    :
    at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3319)
    at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3415)
    at android.app.ActivityThread.access$1100 (ActivityThread.java:229)
    at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1821)
    at android.os.Handler.dispatchMessage (Handler.java:102)
    at android.os.Looper.loop (Looper.java:148)
    at android.app.ActivityThread.main (ActivityThread.java:7325)
    at java.lang.reflect.Method.invoke (Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
    Caused by: android.app.Fragment$InstantiationException:
    at android.app.Fragment.instantiate (Fragment.java:642)
    at android.app.FragmentState.instantiate (Fragment.java:114)
    at android.app.FragmentManagerImpl.restoreAllState (FragmentManager.java:1880)
    at android.app.FragmentController.restoreAllState (FragmentController.java:123)
    at android.app.Activity.onCreate (Activity.java:1048)
    at com.unity3d.player.UnityPlayerActivity.onCreate (Unknown Source)
    at com.unity3d.player.UnityPlayerNativeActivity.onCreate (Unknown Source)
    at android.app.Activity.performCreate (Activity.java:6904)
    at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1136)
    at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3266)
     
  48. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    835
    This issue was fixed in the following Unity versions: 2017.3.0b8, 2017.2.0p2, 2017.1.2p3, 5.6.4p3.
     
    Yury-Habets likes this.
  49. kayyum

    kayyum

    Joined:
    Dec 14, 2017
    Posts:
    1
    Hello ,

    also i have fetch crash issue and describe full details as bellow..

    We have use chartboost 7.00 plugins for unity 2017.2.0f3, and also ads show on over games , but issue is play store details show crash issue and those crash not show Owen devises , issue log write as below please review it and replay us....

    java.lang.NullPointerException: at com.chartboost.sdk.CBImpressionActivity.onCreate (SourceFile:64)
    at android.app.Activity.performCreate (Activity.java:6100)
    at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1112)
    at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2468)

    Thanks
     
  50. pakuetian

    pakuetian

    Joined:
    Oct 24, 2016
    Posts:
    1
    Thanks for this fix.

    We need to fix this in unity version 5.5.1
    Can you please let us know how to fix in 5.5.1?

    We know you have not backported this fix to 5.5, but we need to fix in 5.5.1. We are desperately looking to fix in 5.5.1.
    Please let us know how to fix in 5.5.1.

    email: habib.rehman@hotmail.com

    Thanks and Regards,
    habib