[JAVA] 3 ways to import the library in Android Studio

There are 3 types.
A. Place the jar under libs The file name of the jar is android-support-v4.jar. Create $ {module} / libs folder Change the module accordingly. Place the jar file in the $ {module} / libs folder Add as follows to specify the jar path in $ {module} /build.gradle
dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile files('libs/android-support-v4.jar')
}
B. Load the project folder in the library Used when incorporating facebook sdk etc. This time, we will use Git Submodule to import the library. I used John Persano / SuperToasts as the library to import. If you have a library project, you can just add dependencies.
C. Bring locally from an external repository It can be used when jar or aar is published in Maven Central etc.

Add the description to specify the repository to $ {module} /build.gradle.

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile files('libs/android-support-v4.jar')
    compile project(':SuperToasts:supertoasts')
    compile 'com.github.sakebook:DialogHelper:0.1.1@aar'
}

Recommended Posts