Create a custom app base on the Skeleton app

Hi everyone

Please i need some help

I want to create a custom application using the sdk, I cloned the skeleton to be able to add my features,

  • a crash error saying that the D2 not yet instantiated each time the application is started
  • dependencies should I use for treeviews for orgunits and certain other views

Thanks in advance

Hi @juliennetrenou,

Regarding the first issue, it is required to instantiate the D2 instance before using it (check this section of the docs). Are you getting this error from existing code in the Skeleton app or from code you added later?

About the treeviews for orgunits and other view, @andresmr, @FerdyRod or @manu.munoz could you help here?

1 Like

We have an implementation for this that looks like:

The implementation of this component is in here:

We instantiate OUTreeFragment, this an be an example:

new OUTreeFragment.Builder()
                .onSelection(selectedOrgUnits -> {
                    presenter.setOrgUnitFilters((List<OrganisationUnit>) selectedOrgUnits);
                    return Unit.INSTANCE;
                .show(getSupportFragmentManager(), "OUTreeFragment");

This example can be found in, of our repository : GitHub - dhis2/dhis2-android-capture-app: DHIS 2 data and tracker capture app for Android

I hope this helps you how we managed to do it. In the future we will expose it to let developers use as a library but for now you will need to inspire in our code.
Let me know if you have any doubt.

1 Like

I get the error from the existing code


I see that it has already been implemented in the official dhi2 android capture app

as I use the skeleton, I don’t really know how to proceed

Hi Julienne,
For the first issue, VĂ­ctor is checking it.
For the second, the org unit, currently we don’t provide it in the skeleton (we will in the future). So for now, what I would do is to copy the code that we have in the capture app and use it in your own application, I don’t have a better solution in short term.

1 Like

Thanks you

Hi @juliennetrenou,
I can use the skeleton app without any issue (login, sync,…). I tried closing the app and opening again, all good. Which is the exact error you are getting? Can you share a screenshot or the stacktrace? If your app is in a public repo, I can run it and check it out