How can I use specific classes when building an apk with Android Studio?

121 views Asked by At

I searched a little about this here but didn't found anything that helps me, maybe because it's impossible but I need confirmation.

The situation is the following: I have an android app that integrate with many mobile POS, these card machines, and because I have many classes to integrate with these machines, the app became heavy for some POS stores, like Stone.

I saw that it's possible to implement the libs modules and dependencies for specific flavors with android, so I would generate an specific app, with just the classes that this integration use and nothing more, but I have everything together now, just like in the pics.

And when I build an app that will be used with Stone, for example, it will put all integrations in the JS interface.

I stated changing it, implementing by flavor but as the implementation is per integration now, the Cielo class starts having problems with its dependencies because, as the app will be for Stone, it doesn't download the Cielo dependencies. The generation process crash. When I started changing the structure, I manage to make the gradle build work, but after that, everything crashes.

There is something I can do ? Maybe impost only when the Cielo package really exists, or something like that.

If its needed to change the entire structure, it's ok, I just need to make it smaller but still in one place.

Thanks!

I tried using flavors and separating the source sets alongside main directory, like:

-main
--assets
--java

-cielo
--java

-stone

but it still have a problem when building because the import inside my main class.

1

There are 1 answers

1
Viacheslav Smityukh On BEST ANSWER

You can split your application to multiple parts:

  1. Main application which implements the app's features except an integration.
  2. Android service API which defines API between the main application and an integration service
  3. Integration services one for every platform. Each service have to implement API from point 2 to provide required contracts to the main application.

Finally you can deploy the main app and only one required integration service.