Break services out into separate modules
Adding async consumption options has helped with the Java SDK's consumability on Android, however there's still the problem of it being quite large. Including the Java SDK pushes Android apps dangerously close to the ~65k method limit. In order to allow for better consumption for Android development we should break each service out into separate modules so developers only have to include services they plan on using. This follows the model Google Play Services use, where you can still download the entire SDK if you desire, but you can also download one service without having to download all others.
I think okhttp is doing something like this so we should take a look at what they are doing...
+1
(ง •̀_•́)ง
To support Android users, we could check the Java SDK for compatibility with ProGuard. That way, the unneeded methods can be removed automatically by Proguard, which is very common among Android projects.
@Hsaylor what do you think? can we have this process described in the android-sdk ?
While I'm rather inexperienced with ProGuard, it seems like a possible solution. However, I think at the end of the day it's a question of SDK design. I personally think breaking everything out into separate services is still the better option, again referencing that Google Play Services and OkHttp do this as opposed to saying "just use ProGuard". Simply put I suppose my argument comes down to "why remove extra code when you could just not include it in the first place?"
Two options: 1.Use maven profile to build several independent jars. 2.Change the project structure to multiple modules maven/gradle project. Thoughts?
I totally agree with @Hsaylor's view on SDK design.
1.Use maven profile to build several independent jars.
There are many StackOverflow posts and even one Sonatype blog post that warn about this. Personally, I'm seeing some problems here when users depend on multiple of these independent jars, which share the same common code (e.g. http.*)
2.Change the project structure to multiple modules maven/gradle project.
I think this would be the only viable option, even though the effort shouldn't be underestimated. Modularity means splitting up the project into:
- one base module as shared dependency (containing
http.*, util.*, service.*) - 18 modules
- one master module, depending on all 19 submodules
We should keep java-sdk as the module that has all the other modules.
Then we can use something like personality-insights-v2, visual-recognition-v2-beta.
@jsstylos ?
Another option would be to do modules per service as opposed to per version. (This wouldn't be as optimized for space, but maybe more logical.)
If java-sdk has all of the other modules would there be a separate common module, so that users who just wanted a single service would import the service module which would pull in the common module?
There will be a common project and each module will import that project. The java-sdk module will import all the services.
@germanattanasio And each module will be an entire service wrapper as opposed to a version? So I just add a dependency on the nlc module and get all versions? (that would be my preference at least)
Yeah, I think you we are all on the same page here. Can someone take this task, fork the repo and do a first pass moving the services to different repos? I completely booked until July 14
Well, I guess I will have to do it 😒
I've got you, @germanattanasio! I had some free time so I wrote an example of breaking things out using the language translation service. Check the modules-for-android branch and tell me what you think
I'll take a look at it @Hsaylor. I tried to do it during the weekend but it was more work than what I thought
I realized I pushed up the wrong thing >< Although the concept is the same, it might be a bit harder to see what's going on in that project...
@germanattanasio I pushed up a much cleaner version to the modules-for-android branch, which includes all services. Examples and Tests are currently broken, as they haven't been updated to reflect the refactor, but the structure should be much more clear.
got it. I will take a look at it this weekend