How to include module to the project?

Viewed 4378

There is a lib

https://github.com/Yalantis/uCrop

There are 2 modules Sample and ucrop - where all the logic is situated

Problem is - when I am copying the ucrop module to my project also added this

dependencies {
...
 implementation project(':ucrop')
....
}

and this

settings.gradle include ':ucrop', ':app'

As far as I know I need add only this lines to include new module to the project

Then I am trying to compile the app and get such error

Resolving this BuildableArtifact can only done during task execution.

The module 'ucrop' is an Android project without build variants, and cannot be built. Please fix the module's configuration in the build.gradle file and sync the project again.

What is the reason that my project doesn't want include new module?

Feel free ti ask

Thanks

3 Answers

Clone the repository which you want to be included as a module.

Provide the path of your cloned repository. Now suppose if I want to include Calendar module to my project.

1.Now go into android studio Click File->New->Import module.

2.Add this line to app's build.gradle

implementation project(':calender')

3.Add this line to settings.gradle.

include ':calendar'

Edit : Also you need to modify module's build.gradle file.Under build types you need to add this line

flavorDimensions "default"

Steps to Import Module in Android Studio.

1) Go to File -> NEW-> Import Module...

2) Select the source directory of the Module you want to import and click Finish.

3) Open Project Structure and open newly import Module for your project.

4) Open the Dependencies tab.

5) Click the (+) icon and select Module Dependency. Select the module and click Ok. (if not found Module Dependency then try below way)

6) Open your build.gradle file and check that the module is now listed under dependencies.

-----> Second Way

1) Go to File -> NEW-> Import Module...

2) Select the source directory of the Module you want to import and click Finish.

3) Open settings.gradle of your project, you find newly added module name there, copied that.

4) Open build.gradle file and import module by below dependency

Ex. (if your module name is ClientLibrary)

    implementation project(path: ':ClientLibrary')

5) sync gradle. that all.

  1. In Android Studio, Right click on the app choose New -> Module
  2. Select import .AAR package which need to be incuded and provide the path for in the file name 3 .Right click on your App and choose Open Module Settings
  3. Open App in module setting and click on add button to add module dependency
  4. choose the module to be included .
  5. You can confirm the Module import by changing the Android view to Project view in thesidebar
Related