It is assumed here that both jar and aar are placed in the libs directory of the module.
method one
In the dependencies of build.gradle in the module directory, add
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
This method is simple and rude, but does not allow jars (or aars) of different compilation types of the same module to appear at the same time.
For example, if libs has both test-release.aar and test-debug.aar, they are all packaged from the same module , but only the compilation types are different. If they exist at the same time, they will not compile.
Full version
apply plugin: 'com.android.application'
android {
...
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
...
}
Method 2
Add in the module's build.gradle first
repositories {
flatDir {
dirs 'libs'
}
}
Same level as dependencies
and then add in dependencies
implementation(name:'xxx', ext:'aar')
// 或
implementation(name:'xxx', ext:'jar')
full version
apply plugin: 'com.android.application'
android {
...
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
implementation(name:'xxx-debug', ext:'aar')
//或
implementation(name:'xxx-debug', ext:'jar')
}