Android Studio - Creating Modules Without Copying Files

Android Studio - Creating Modules without copying files?

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.

How to reference without copying a library project on Android Studio?

Got it:
In your project, go in settings.gradle and declare something like this:

include ':LibReferenceName'
project(':LibReferenceName').projectDir = new File(settingsDir, '../relativePath/toThe/libraryModule/fromTheProject')

And at the modules that requires the library, include something like this in the build.gradle of it:

compile project(path: ':LibReferenceName')

You can also not use settingsDir and just put the absolute path of the project.

How to import a library project in Android Studio, without making a copy?

The real answer to keep your library project only in one place is in this post :

Android Studio 0.8.1 Creating Modules without copying files?

How to create modules in a features(outer) module for Dynamic Features with Android Studio

Not sure about it can be done by Android Studio but the simple way following these steps

  1. You create a Module as normal from Righ Click in app folder
  2. Create Directory with name features, switch to Project structure view and move your Module Directory to features
  3. If you using dynamic-feature-module you have to change in settings.gradle file and build.gradle app.

How do I make an app use a module outside of its own folder, by linking to it (instead of copying)?

Yes you can!

Inside your settings.gradle add:

include ':myModule'

project(':myModule').projectDir = new File('../../MyOtherProject/modules/myModule')


Related Topics



Leave a reply



Submit