0

I know this might seems a duplication of "how to have multiple application classes in separated jars in one application in android" but I'm experiencing this problem with AAR files and I don't know how to get a solution.

The scenario is as follows:

I have an ECR application that should be able to integrate with different payment devices. Each manufacturer has its own SDK in compiled AAR files. Each AAR file comes with an application class.

So, when I join them in my project I get a manifest merger error because each manifest's AAR comes with an "android:name" under the application tag for their application classes. So, I have to use "tools:replace" to avoid such conflict. Now, the problem is: How to load these classes?

In the post I mentioned the solution was to create a chain of extends. So let's say I have manufacturers X, Y and Z and I create my own application class A. So X would extend Y; Y would extend Z, Z would extend A and finally A extends Application.

However, I just can't change the code from these AAR files! They are already compiled from the manufacturer.

Is there any way to work around this and make sure all application classes could be loaded? Maybe by using a class loader os something?

Thank you in advance. Carlos Santos

cmmpsantos
  • 95
  • 9
  • You will have to exclude those modules in gradle file if you are already those classes in other maven. – Akash Feb 02 '18 at 10:54
  • If I exclude them from the project, it won't compile. – cmmpsantos Feb 02 '18 at 10:57
  • If the SDKs really enforce the usage of their application classes, this is bad SDK design. Might be possible that your own application class can implement some interfaces that would satisfy your other SDKs? An example for this is https://github.com/google/dagger/blob/master/java/dagger/android/DaggerApplication.java You can use this application, when you want to use DaggerAndroid, but you're not forced to use it, because your own application class can implement the interfaces `HasActivityInjector`, ... by its own – Christopher Feb 02 '18 at 11:01
  • No. I found that, in most cases, the SDKs use their application classes just to get the application context. Others have some few more methods. And I agree with you regarding a bad SDK design. This just kills any software that wants to provide several different solutions. In this case a ECR/POS software offering different options for electronic payment devices. :( – cmmpsantos Feb 02 '18 at 11:39

0 Answers0