50

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

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
user3395396
  • 611
  • 1
  • 5
  • 5
  • 1
    Follow : http://stackoverflow.com/questions/21130003/using-viewpagerindicator-library-with-android-studio-and-gradle – ZaptechDev Kumar Jan 20 '17 at 13:06
  • Possible duplicate of [Using ViewPagerIndicator library with Android Studio and Gradle](http://stackoverflow.com/questions/21130003/using-viewpagerindicator-library-with-android-studio-and-gradle) – samiles Jan 20 '17 at 15:00

7 Answers7

108

Steps to import Module in Android Studio 3.3 and lower.

  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 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')
steveluscher
  • 4,144
  • 24
  • 42
Aman Shekhar
  • 2,719
  • 1
  • 18
  • 29
  • 7
    file>>>NEW>>>>import... That NEW is so important in latest version – Lakhwinder Singh Dhillon Oct 29 '17 at 13:58
  • @Shekhar Sir can you take a look at this question https://stackoverflow.com/questions/57779798/add-module-dependency-for-imported-module-shows-blank-screen thank you for your time. – peco Sep 04 '19 at 10:27
  • 1
    I am unable to find Module Dependency in the dropdown. Only Library dependency and JAR dependency are available. What should I do? (Android Studio 4.1.2) – Abdullah Javed Mar 11 '21 at 14:57
  • It doesn't work. If I go to File > New > Import Module, it wants me to import an entire project, but I just need to import one Java file. – Donald Duck Aug 09 '21 at 12:28
  • @DonaldDuck, what is your question. If you want to import just one java file, then just do copy paste. The above procedure I wrote is to "Import a Module". – Aman Shekhar Aug 10 '21 at 13:25
10
  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.
Sushin Pv
  • 1,826
  • 3
  • 22
  • 36
Mehul Kabaria
  • 6,404
  • 4
  • 25
  • 50
  • Error:Dependency DialoFragmentdemo:app:unspecified on project ViewPagerIndicator-Library resolves to an APK archive which is not supported as a compilation dependency. File: C:\Users\Saurabhk\DialoFragmentdemo\app\build\outputs\apk\app-release-unsigned.apk – user3395396 Jan 23 '17 at 07:38
  • @Mehul Kabaria Sir can you take a look at this question https://stackoverflow.com/questions/57779798/add-module-dependency-for-imported-module-shows-blank-screen thank you for your time. – peco Sep 04 '19 at 10:27
10

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

enter image description here

Then select your Java library.

Siddarth Kanted
  • 5,738
  • 1
  • 29
  • 20
4

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>'
sharma_kunal
  • 2,152
  • 1
  • 28
  • 28
3

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

Gk Mohammad Emon
  • 6,084
  • 3
  • 42
  • 42
3

In case you have a module in your android project called library for example, and you want to add this module as a library to another module called app for example, in that same android project, here's what just worked for me, add this inside your app module's build.gradle:

dependencies {
    implementation project(path: ':library')
}
Kevin Germain
  • 471
  • 3
  • 6
0
  1. Go to File > New > Project Structure
  2. In the left you see Dependencies, click on it
  3. All Modules need to be chosen
  4. Click + and Library Dependency
  5. Search module that you need