androidvariantandroid-module

How to access a module into another module of Android


I'm having few different variants and for each variant I'm having different module into my project but now I got a new requirement where I'll have to use an existing module in a new build variant. It means if any changes happen in code of variant1 the changes should be reflected in the apps of variant1 and variant3. Hope my query is clear. enter image description here

In above image,

  1. main is the common module for each type of variant
  2. verify is the module which is completely different
  3. wallet is the module what I want to use in a new module i.e. companion

Please guide me if there is a good solution to use it. Currently I'm copying whole files of wallet into companion which is not feasible solution for future.


Solution

  • let's assume we have moduleA and moduleB, to access moduleB inside of moduleA add implementation project(":moduleB") to moduleA build.gradle file.

    Note that all files inside moduleB will be available to moduleA but files inside moduleA aren't available to moduleB

    be sure to declare your modules in settings.gradle

    include ':moduleA'

    include ':moduleB'