We have a multi-module android project, which we began to refactor to a kotlin-multiplatform project with several modules to share with our iOS app.
Our multiplatform project currently has 4 modules: domain, presentation, data and shared-app. The shared-app module depends on the other three modules and this is the module which is imported into the old android project. We merge the modules into a single one to generate only a single Framework for the iOS project.
Both projects build sucessfully. But if we retrieve an interface instance which is defined in the shared-app module which uses types from the submodules, the IDE shows [ERROR : SomeType] for its return types.
In our old android projects settings.gradle, we used includeBuild(mpp-project) and created a dependency substitution for the shared-app module in the mpp-project.
enableFeaturePreview("GRADLE_METADATA")
includeBuild("mpp-project") {
dependencySubstitution {
substitute(module("our.package.name:shared")).with(project(":shared-app"))
}
}
On the other hand, all of our exposed and transitively imported type can be instantiated in the old android project, even from the submodules. (for example I can instatiate SomeType and it resolves)
Gradle project structure:
oldAndroidRootProject
├─myApp (import implementation of all androidModules and mppFramework)
│ └─build.gradle
├─androidModule1
│ └─build.gradle
├─androidModule2
│ └─build.gradle
├─androidModule3
│ └─build.gradle
│
├─myMppRootProject
│ ├─mppFramework (depends on mppModuleXs and dependencies are declared as api(":mppModuleX"))
│ │ └─build.gradle
│ ├─mppModule1
│ │ └─build.gradle
│ ├─mppModule2
│ │ └─build.gradle
│ ├─mppModule3
│ │ └─build.gradle
│ ├─mppModule4
│ │ └─build.gradle
│ ├─build.gradle
│ └─settings.gradle (uses includeBuild("myMppRootProject"))
├─build.gradle
└─settings.gradle (uses includeBuild("myMppRootProject"))
If I check the mppFramework modules source, when the androidRoot project was opened I see this:

