Importing Module in Android Studio

How can I import an external module (named ViewPagerIndicator) in Android Studio?


Solution 1:

Steps to import Module in Android Studio 3.3 and lower.

  1. Go to Fill >> New >> Import Module...
  2. Select the source directory of the Module you want to import and click Finish.
  3. Open Project Structure and open Module Settings for your project.
  4. Open the Dependencies tab.
  5. Click the (+) icon and select Module Dependency. Select the module and click Ok.
  6. Open your build.gradle file and check that the module is now listed under dependencies.implementation project(path: ':ViewPagerIndicator')

Steps to import Module in Android Studio 3.4 and higher (See attached image).

  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 Dialog (You can open the PSD by selecting File > Project Structure) and from the left panel click on Dependencies.
  4. Select the module from the Module(Middle) section In which you want to add module dependency.
  5. Click the (+) icon from the Declared Dependencies section and click Module Dependency.
  6. Select the module and click Ok.
  7. Open your build.gradle file and check that the module is now listed under dependencies.implementation project(path: ':ViewPagerIndicator')

Solution 2:

To import an existing Java library to an android project. Do the following.

enter image description here

Then select your Java library.

Solution 3:

  1. Click on File and select Import Module option.
  2. Open of select your ViewPagerIndicator module from local.
  3. add compile project(path: ':ViewPagerIndicator') in your gradle file.

Solution 4:

This tutorial will help you to do easily that without any code in build.gradle (actually system will do code for you).

Solution 5:

I was also facing the same issue. Please make sure below steps

1)build.gradle :-
     implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(path: ':<Project-name>')

2) settings.gradle
     include ':<Project-name>'