JAR Packages
Place JAR files into the libs folder inside the app module. Update the app-level build.gradle dependencies block using one of two approaches.
To bundle all JAR files from the directory at once:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
}
Alternatively, reference each archive individually:
dependencies {
implementation files('libs/image-processor-2.1.0.jar')
}
Remote JAR artifacts hosted on servers follow a compact notation: implementation 'group:artifact:version'.
dependencies {
implementation "com.squareup.retrofit2:retrofit:2.9.0"
}
AAR Archives
AAR packages bundle compiled code together with resources such as layouts and drawables. Two integration paths exist.
Module-Based Import
Navigate to File > New > New Module and choose Import .JAR/.AAR Package. After selecting the archive, a dedicated module folder appears in the project root. Then declare the dependency in the app module:
dependencies {
implementation project(':analytics-sdk')
}
Source inspection inside the imported archive is not available with this method.
Direct libs Placement
Copy the AAR file into the libs directory of the app module. Register the local repository and reference the archive in build.gradle.
android {
// ...
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
implementation(name: 'analytics-sdk', ext: 'aar')
}
Remote AAR artifacts use the same compact format as remote JAR files.
Library Modules
Copy a Library module folder into the root project, or import it via File > New > Import Module. Register the module in settings.gradle:
include ':app', ':scanner-module'
Then connect it in the app module:
dependencies {
implementation project(':scanner-module')
}
For better organization, collect Library modules inside a common parent directory (e.g., extras). Adjust the include statement accordingly:
include ':app', ':extras:scanner-module'
The dependency declaration follows the new path:
dependencies {
implementation project(':extras:scanner-module')
}
Native SO Files
Create a jniLibs folder under app/src/main/ and place the architecture-specific subdirectories (e.g., arm64-v8a) inside it. The Gradle Android plugin automatically packages these native libraries.
Remote jcenter and Maven Artifacts
Declare the required repositories in the root build.gradle:
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Then add the dependency into the appropriate module:
dependencies {
implementation 'com.github.bumptech.glide:glide:4.15.1'
implementation 'io.reactivex.rxjava3:rxjava:3.1.6'
}