Hey guys, Do anyone knows how to add KMP as a modu...
# multiplatform
s
Hey guys, Do anyone knows how to add KMP as a module in existing Android app? I want to keep KMP module as a separate repository. thanks
a
Since you have an Android app, it will allow only android dependency from KMP module. So simply add dependency in android app like implementation(“com.librarylibrary android1.0.0”)
Important part is -android here
🙌 1
d
A small addition to the previous comment: You can build aar from kmp repository and import in android repository in any preferred way
👍 1
s
Thanks @Azim Ansari, i'll look into that.
@Dmitry Stakhov i want to connect kmp repository locally to check my changes with android/ios instantly. I've already tried aar while integrating flutter into my android app, that's was so scary.
d
You can publish aar to maven local and consume it from your android project by adding mavenLocal block to repositories in your Gradle build file
1
s
@Dmitry Stakhov interesting, let me look into that as well.
a
@Shoaib khalid Oh! If you want to include it as local project then also no problem. Just include KMP project from a custom path in settings.gradle file
Copy code
include(":mylib")
project(":mylib").projectDir = File("/absolute/path/to/your/kmp/shared")
Then in Android native add local project dependency
Copy code
implementation(project(":mylib"))
Note: This will include all platform modules but Android app can access only androidMain and common code
🙌 1