I am learning to build Android shared libraries that can be used with different projects. I got a few questions regarding this subject. Before I go into the questions, below is what I have done so far:
My questions are:
I am using Android Studio IDE.
Thank you,
Ah yes, this can be very helpful in many cases. You can do the following to achieve this.
Let's say you have two projects - MyApplication and MyLibraryDemo containing the library module libmodule with the following paths:
MyApplication - "/../AndroidStudioProjects/MyApplication"
MyLibraryDemo - "/../AndroidStudioProjects/MyLibraryDemo"
libmodule - "/../AndroidStudioProjects/MyLibraryDemo/libmodule"
And let's say you are trying to use libmodule in MyApplication. Then, in your settings.gradle
of your MyApplication
project, do this
include ':app', ":libmodule" project(':libmodule').projectDir = new File(settingsDir, '../MyLibraryDemo/libmodule')
You may have to make relevant corrections, but I hope the idea of linking another module is clear.
All the best :)
Importing a module from outside of your application project creates a copy of the library inside of your application. If your system supports it, creating a symbolic link will allow you to have only one copy of the code.
Otherwise, you can move the entire library project into your application and add it to your settings.gradle.
If you wish to have separate git repositories for both of these projects, look into using git submodules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With