转载自http://blog.csdn.net/zhanglianyu00/article/details/51597362
(1)将编译好的aar文件放到app/libs下,类似jar的做法。譬如,libs/HDDecodeLibrary_1.1.03_a.aar。
(2)在工程的当前module的gradle(app/build.gradle)的dependencies节点前添加:
repositories {
flatDir {
dirs 'libs'
}
}
并且在dependencies中添加:
compile(name: ‘HDDecodeLibrary_1.1.03_a’, ext: ‘aar’)
一个完整的build.gradle例子如下:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "sim.com.scannertest"
minSdkVersion 24
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { res.srcDirs = ['src/main/res', 'src/main/res/raw'] } }
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile(name: 'HDDecodeLibrary_1.1.03_a', ext: 'aar')
}