Shinobi Charts for Android with Android 4.4 KitKat


Has much testing been done on 4.4?  I am seeing quite a few errors, and fatal exceptions being spewed from Shinobi on all 4.4 devices, was there any fundamental change which needs to be accounted for?

They seem to all come back to this point:

12-12 13:56:46.186: E/AndroidRuntime(30905): java.lang.NullPointerException
12-12 13:56:46.186: E/AndroidRuntime(30905): at com.shinobicontrols.charts.r.onSurfaceChanged(SourceFile:136)
12-12 13:56:46.186: E/AndroidRuntime(30905): at com.shinobicontrols.charts.GLTextureView$f.l(SourceFile:1539)
12-12 13:56:46.186: E/AndroidRuntime(30905): at com.shinobicontrols.charts.GLTextureView$


edit: ignore this edit, original posts still holds true :slight_smile:


I also notice that on another Activity the graph continues to grow, as in the X-Axis increases, but no data is ever plotted.  Leaving this activity leads to this crash.  Works on  4.0, and 4.1 and did on 4.2 but I dont have one handy to test on at the moment.



Yes, we do run all our tests on a variety of devices, including a Nexus 10 with 4.4. But I don’t think that’s the issue here. That particular exception is usually seen when you use ChartView (rather than ChartFragment) and don’t pass the onPause and onResume calls from your activity through to the ChartView. This is required to ensure that Android hits the onSurfaceCreated/Changed/Destroyed methods in the right order on the chart’s renderer class, which is the class obfuscated as .r. There’s a reasonably complete example of this in the How to: Manage Chart Lifecycles user guide.




Thanks Robin, I didnt mean to imply a lack of testing, I just simply couldnt remeber if 1.2 was released before or after 4.4 was made public.  Was just looking for assurance that it was my fault :slight_smile:  Sounds like you are desribing the issue properly tho, so Ill give it a shot.


Is there an android version of this example you speak of?  I can only seem to find an iOS version



Don’t worry, I wasn’t taking your question about testing the wrong way. :slight_smile:

The user guides are in the download bundle, under the docs folder, and there’s a sample app CustomDataAdapterChartView which illustrates it too.

Best regards,



Hi Robin,

Thanks for the document, very useful, but it has me thinking of a better option for my implementation.  Unforunetly I am forced into using ChartView as the chart sits in a fragment which is controlled by a ViewPager.  But I wondering… is it possible use nested ChartFragments using the support library for <4.2? I’d love to be able to use all the great stuff you’ve done with the fragment encapsulation!



It’s not something we’ve tried ourselves but seeing as our SupportChartFragment extends the Frament  in the supoport library, the Android docs suggest it probably would (

The Android Support Library also now supports nested fragments, so you can implement nested fragment designs on Android 1.6 and higher.

Like I say though, I’ve not actually tried it. Let us know how you get on!



Hi, I tried what the Android docs suggest ( with SupportChartFragment, unfortunately it did not work because by default, a ChartFragment (so SupportChartFragment is) is retained across Activity re-creation, and i got this exception 03-06 14:57:28.400 [...] E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: [...], PID: 12555 java.lang.IllegalStateException: Can't retain fragements that are nested in other fragments at at com.shinobicontrols.charts.SupportChartFragmentBase.onCreate(SourceFile:42) at com.shinobicontrols.charts.SupportChartFragment.onCreate(SourceFile:41) at at at at at at at at at at at$ at android.os.Handler.handleCallback( at android.os.Handler.dispatchMessage( at android.os.Looper.loop( at at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke( at$ at at dalvik.system.NativeStart.main(Native Method) Did someone succeed to use a ChartFragment in a fragment ? Thanks.


Hi ckitop,

As you have found, placing a ChartFragment within another Fragment won’t work for precisely the reason you have seen here - that our ChartFragment/SupportChartFragment is retained across Activity re-creation and the Android framework does not allow retained Fragments within other Fragments.

My suggestion would be to create your own Fragment that contains a ChartView - the layout for this Fragment can consist of just the ChartView; there’s no need for it to sit inside another ViewGroup. You will have to ensure you forward the appropriate lifecycle calls from the Fragment to the ChartView but this doesn’t involve too much work: the most important ones are onPause and onResume - simply override these methods in your Fragment and as well as calling the method on super, also call it on the ChartView.

This should then allow you to put your Fragment inside another Fragment. As it can’t be retained over Activity re-creation you will have to think about how the lifecycle will affect your Fragment and ChartView.

Kind regards,



to not have the following issue as previously described. I can’t find the example project you are referring to.


       at com.shinobicontrols.charts.w.onSurfaceChanged(SourceFile:145)

       at com.shinobicontrols.charts.GLTextureView$f.l(SourceFile:1539)

       at com.shinobicontrols.charts.GLTextureView$

do I just override in my fragment 

public void onResume(){





    public void onPause(){





Patrick, could you elaborte a little more on adding a ChartFragment into a fragment?

I’m still facing the issue ckitop described (Caused by: java.lang.IllegalStateException: Can’t retain fragements that are nested in other fragments), when I try to add the ShinobiControls ChartFragment to a Fragment.

Any help would be highly appreciated!


Hi Maximillian,

I notice you say that you are trying to place a ShinobiControls ChartFragment into a Fragment. As Pat has mentioned, our ChartFragment/SupportChartFragment is retained across Activity re-creation and the Android framework does not allow retained Fragments within other Fragments.

The solution is to use a ChartView object instead. As Pat mentioned, you would need to place a ChartView inside a Fragment. You’ll need to forward the life-cycle callbacks, such as onPause and onResume to the ChartView object.

For a basic example of how to use a ChartView, look for the project named ‘customdataadapterchartview’ in the ‘samples’ directory of the download bundle. 

I hope this helps,