lundi 22 juin 2015

Android - multiple Gson libs in different SDKs

We are using couple of SDKs with our app and some of them have Google Gson library but in different package e.g. thirdpartylib.gson.Gson, thirdpartylibsecond.gson.Gson, .... We use com.google.gson.* package as well but the thing is: Is there any way how to use one of the Gson from other SDKs instead of ours? The main reason is to reduce number of method IDs.

We are thinking about using reflection something like:

1) Create our stub class for Gson and use it everywhere in our app -> GsonStub.

2) Check if any other Gson is available: Class cl = Class.forName('<specific-gson>')

3) and then use method delegation in our GsonStub: cl.getDeclaredMethod()

But problem is that another our 3rd party library takes com.google.gson.Gson as parameter. Moreover, each call of Gson method in this implementation could cost us extra resources because of reflection.

Has anyone got experience with this 'issue'? It seems ineffective to have linked number of same Gson libs each with around 900 method IDs.





Aucun commentaire:

Enregistrer un commentaire