I'm creating projects with dependencies in Android Studio. I know how to link projects by adding modules.
But I realized that 'importing modules' create a copy of the libProject inside the project.
Is there a way to prevent that ? Like an 'external module' ?
Since i'm in charge of both project, I want to be able to push changes to the libProject Repo, without having to copy paste files between folders.
Thanks
Android Studio uses modules to make it easy to add new devices to your project. By following a few simple steps in Android Studio, you can create a module to contain code that's specific to a device type, such as Wear OS or Android TV.
AAR files can contain Android resources and a manifest file, which allows you to bundle in shared resources like layouts and drawables in addition to Java classes and methods. AAR files can contain C/C++ libraries for use by the app module's C/C++ code.
Select the source directory of the Module you want to import and click Finish. Open Project Structure Dialog (You can open the PSD by selecting File > Project Structure) and from the left panel click on Dependencies. Select the module from the Module(Middle) section In which you want to add module dependency.
A project with multiple Gradle modules is known as a multi-module project. This guide encompasses best practices and recommended patterns for developing multi-module Android apps. Note: This page assumes a basic familiarity with the recommended app architecture.
Yes, you can do it. The module needs to have a Gradle build file set up for it. If it's got that, then in the project you're linking to it, add this to the settings.gradle file at the project root:
include ':libraryName' project(':libraryName').projectDir=new File('/path/to/library')
where the path you specify in the second line is the path to the directory containing the library's build.gradle file. The path can be relative or absolute.
The solution:
include ':libraryName' project(':libraryName').projectDir=new File('/path/to/library')
was not working for me. After couple of wasted hours I figured out the issue. There are two build.gradle
files, one for project and one for library name. If the library is in the folder '\MyLib' then there will be a build.gradle
in '\MyLib' and another at '\MyLib\app'. You have to point to the '\MyLib\app' and not '\Mylib'.
Hopefully this saves some time for others.
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